Skip to content

Programming Notes

Deep systems programming notes covering ownership, templates, concurrency, and build systems.

Compilation Model

Types

Resource Management

Object Oriented

Standard Library

Concurrency

How to Use These Notes

  1. Start with the fundamentals — build a solid foundation before moving to advanced topics
  2. Work through examples — follow along with the worked examples to build intuition
  3. Test yourself — use the practice problems and flashcards to check your understanding
  4. Review regularly — spaced repetition helps retain what you have learned## Cross-References

Common Mistakes

Forgetting rule of zero/three/five: If your class manages a resource, define or delete the copy constructor, copy assignment, move constructor, and move assignment. If it does not, the compiler-generated defaults may silently cause double-free bugs or shallow copies of owned resources.

Using raw new/delete instead of RAII: Manual memory management with new and delete is error-prone — exceptions, early returns, and forgotten cleanup cause leaks and dangling pointers. Use smart pointers and stack allocation to bind resource lifetime to scope.

Assuming std::move moves data: std::move casts an lvalue to an rvalue reference — it does not itself move anything. The actual move happens in the move constructor or move assignment operator. Misusing std::move on objects after they have been moved-from leads to undefined or surprising behaviour.

Cross-References

Intuition

C++ systems programming is fundamentally about owning and managing resources. Unlike garbage-collected languages where the runtime cleans up after you, C++ puts you in control of memory, file handles, network connections, and other resources. The key insight is that resource lifetimes can be tied to object lifetimes through RAII — when an object is constructed, it acquires a resource; when it is destroyed, it releases it. This simple idea eliminates entire classes of bugs like memory leaks and dangling pointers.

The type system, ownership model, and compilation model all serve this central goal. Understanding how code goes from source text to machine code (the compilation model), how data is laid out in memory (types and references), and how to transfer ownership safely (resource management) gives you the mental model needed to write C++ that is both efficient and correct. The standard library builds on these foundations with containers, algorithms, and utilities that follow the same principles.

When approaching these notes, think of each section as a layer of the same onion: the compilation model tells you what happens to your code, the type system tells you how data is represented, resource management tells you who is responsible for that data, and the standard library gives you battle-tested tools built on top of it all.