Lumenary CS · Programming languages
C++
Modern C++ from a first program to professional practice: value semantics, RAII, templates, the standard library, concurrency and the tools that keep large codebases correct.
C++ is a compiled, statically typed language that gives you two things at once: direct control over memory and the machine, and abstractions (classes, templates, the standard library) that cost nothing at run time when you do not use them. It runs inside web browsers, game engines, databases, compilers, trading systems, robots, scientific simulations and the cores of machine-learning frameworks. It is also large, old and full of sharp edges, so this course teaches modern C++ (C++20 and C++23) as experienced engineers write it today, and is honest about the parts that still bite.
The course assumes the Start level of Lumenary CS or equivalent experience: you know what a variable, a loop and a function are. No C is required. It takes you from compiling your first program through references, classes, RAII, move semantics, templates and concepts, containers and ranges, to error handling, undefined behaviour and sanitizers, threads and atomics, CMake and package managers, and a complete small project. Every complete program in the lessons was compiled with GCC 14 (g++ -std=c++23 -Wall -Wextra) and run, and the output shown is the output it printed.
To run the programs, install a C++ compiler: GCC (on Linux, from your distribution; on Windows, through MSYS2 or WSL), Clang (on macOS, xcode-select --install), or Visual Studio with the Desktop development with C++ workload on Windows. C++ has no official online playground; the community's standard one is Compiler Explorer, which compiles and runs code with dozens of compilers in your browser and shows the machine code they produce.
- Chloe · The Designer
“Why is the language built this way?” - Margaret · The Profiler
“What does it print, and what does it cost?” - Gideon · The Language Lawyer
“What exactly does the language guarantee?”
Foundations · 4 lessons
The core language
How C++ programs are compiled and linked, values, references and const, functions, overloading and lambdas, and classes whose destructors clean up after them (RAII).
- 1First steps with C++Where C++ came from, what it is for, and how source code becomes a running program. 45 min
- 2Values, references and constWhat a C++ variable really holds, how copies and aliases differ, and how const lets the compiler hold you to your word. 55 min
- 3Functions, overloading and lambdasDeclaring and defining functions, choosing between overloads, returning several results, and writing small functions inline as lambdas. 55 min
- 4Classes and RAIITypes that keep their own promises, and destructors that clean up so you never have to remember to. 60 min
Practice · 3 lessons
Ownership, generic code and the standard library
Move semantics and smart pointers, templates constrained by concepts, and the containers, iterators, algorithms and ranges of the standard library.
- 5Ownership, move semantics and smart pointersWho owns each object, how ownership is handed over without copying, and the rule of five for the rare class that manages memory itself. 65 min
- 6Templates and conceptsWriting code once for every type that fits, and saying precisely which types fit. 65 min
- 7The standard library: containers, iterators, algorithms and rangesThe data structures every C++ program uses, the iterators that connect them to a hundred ready-made algorithms, and the composable views of C++20 and C++23. 65 min
Professional · 3 lessons
Correctness, concurrency and real projects
Exceptions and std::expected, undefined behaviour and the sanitizers that find it, threads, mutexes and atomics, and a complete project built with CMake, a package manager and the C++ Core Guidelines.
- 8Errors, undefined behaviour and sanitizersExceptions and std::expected for the failures you plan for, and undefined behaviour, hardened libraries and sanitizers for the bugs you do not. 70 min
- 9Concurrency: threads, mutexes and atomicsRunning work on several cores at once without data races, using jthread, locks, condition variables, atomics and futures. 70 min
- 10A project: CMake, packages and the Core GuidelinesA complete small program in idiomatic C++23, the build system and package manager around it, and how professional teams keep a C++ codebase healthy. 75 min
Further reading and resources
- Standard C++ Foundation (isocpp.org)News, the FAQ, and where the standards committee's work is published.
- The C++ standardHow to obtain the ISO standard and the freely available working drafts.
- cppreference.comThe reference professionals keep open: every language feature and library facility, with the standard version that introduced it.
- C++ Core Guidelines · Bjarne Stroustrup and Herb Sutter (editors)Rules for writing safe, modern C++, each with a rationale; cited throughout the course.
- Compiler ExplorerThe community's online playground: compile and run C++ with many compilers and see the generated assembly.
- GCC, the GNU Compiler CollectionThe compiler the course's programs were tested with (GCC 14).
- Clang: a C language family frontend for LLVMThe other major open-source compiler, with clang-tidy, clang-format and the sanitizers.
- Bjarne Stroustrup's home page · Bjarne StroustrupThe designer of C++: his books, papers on the language's history, and FAQs.