C/C++ Language Primers
CS 300 teaches you the fundamentals of computer systems, using the C and C++ programming languages. C and C++ are the two most widely used systems programming languages in industry today; millions of programs including your operating system and the web browser you're using to view this page are written in C and C++.
C and C++ are valuable for every software engineer to know. They are powerful, but also dangerous, tools that give you more control over your computer, and more insight into its magic, than almost any other language.
C
C is an old programming language – it's been around since the 1970s! But despite its simple syntax, it is very powerful and versatile. We will go over the language in lectures, but lectures will move quickly, so additional reference material can be useful.
We recommend these resources:
- The CS 300 TAs' C Primer is a concise overview of C language syntax and features, as well as helpful debugging tips, and comes in three parts: Part 1, Part 2, and Part 3. Make sure to check this out first, since it's tailored towards the course!
- C Standard Library Refrence from cplusplus.com. Despite the domain name, this site has excellent documentation for the C standard library (other parts of the site are a good C++ reference!).
- The C Programming Language by Brian W. Kernighan and Dennis M. Ritchie (also known as "K&R"; Prentice Hall PTR, ISBN 0-13-110362-8) is the classic textbook for programming in C.
- Harvard CS 61's C Patterns explains some handy common tricky that will be useful for your assignments.
- Linux/OS X/BSD man pages! They're very detailed, but often tell you important
details about library functions. Type
man 3 <library_function>
to open the man page forlibrary_function
(e.g.,strncpy
).
C++
C++ is a popular language for low-level systems coding, and unlike C, its predecessor, it comes with an extensive data structure library and high-level abstraction facilities. Though the course uses C++, it is about systems programming, and we will not use (or teach) the complex object-oriented features in C++ and attempt to avoid its most confusing concepts.
That said, getting familiar with C++'s data structures and libraries will be useful. You can get this information from free resources on the web. Some web resources are almost overwhelmingly detailed, but don't despair! It often works to scroll through reference pages for example code, which can be more concise and clear than the English-language reference material.
We recommend the following resources for C++:
- Harvard CS 161's C++ guide succinctly explains the key differences between C and C++. It explains some of the C++ concepts you may encounter in documentation or compiler error messages (e.g., constructors, destructors, etc.).
- C++ tutorials from LearnCpp.com
- C++ tutorial from cplusplus.com
- C++ tutorial from w3schools.com LearnCpp.com has an extensive set of tutorials. The cplusplus.com one is a good short tutorial.
- C++ reference from cplusplus.com
- C++ reference from cppreference.com As of 2019, cplusplus.com's text is more approachable, though its layout is uglier and its technical material slightly out of date.
Acknowledgment: We thank Eddie Kohler and Harvard's CS 61 course for some of the above references, which we've reproduced with permission in modified form here.