C++
Articles on C++: from the pragmatic fundamentals of the language and regular types to low-level performance, cache behavior, and "abnormal" compiler tricks.
- C++
What new and delete actually do
How the new/delete expressions in C++ differ from malloc/free: constructor and destructor calls, operator new/delete and working with raw memory — with an assembly walkthrough.
- C++
How a vtable works
How a C++ compiler implements virtual functions: the hidden vptr, the vtable and dynamic dispatch — with a hand-rolled implementation using function pointers.
- C++
STL associative containers
STL associative containers: set, map, multiset and multimap — how they differ, when keys are unique and when they repeat, with short examples.
- C++
Heap vs stack tradeoffs
Heap vs stack: determinism, fragmentation, binary size and memory footprint — why in games and on consoles it pays to minimize the heap.
- C++
Squeezing a Megacity Down to iPhone 4 Size
The engineering underbelly of mobile SimCity BuildIt: how a desktop city builder was crammed into an iPhone's 100–300 MB of RAM — a server-authoritative economy on timers, a "dumb" client-terminal, aggressive batching and texture atlases, a TBDR renderer with preview sectors, a gutted simulation with sprite traffic jams, power as Capacity − Demand, and a "classified-ads" market. Plus the story of the St. Petersburg studio EA SPB.
- C++
A field guide to other people's STLs
A tour of the alternative "standard" C++ libraries from game studios and big companies: EASTL and its best practices, LLVM SmallVector/DenseMap, Folly and the anatomy of fbstring (SSO, eager copy, COW, and the jemalloc pairing), boost flat_map, Zmeya's serializable containers, Adobe's Stlab and value-oriented programming — why each appeared and where you can hurt yourself on it.
- C++
C++101 (Part 1)
A catalog of ~100 C++ idioms and techniques that grew out of the Game++ section. Part 1: resources and compilation — RAII, scope guard, copy-and-swap, smart pointer, copy-on-write, Pimpl, interface class, include/inline/export guards, CRTP, Barton-Nackman, EBO, and metafunction.
- C++
C++101 (Part 2)
Part 2: metaprogramming and templates — traits, tag dispatching, int-to-type, type selection, SFINAE and enable-if, member detector, policy-based design, type erasure, thin template, named template parameters, expression templates and result_of, plus named constructors and base-from-member.
- C++
C++101 (Part 3)
Part 3: initialization, polymorphism, and containers — calling virtuals during init, NVI and thread-safe interface, acyclic visitor, covariant return types, virtual friend function, algebraic hierarchy, polymorphic value types, functors, iterator pair, generic container, erase-remove, safe bool, and attorney-client.
- C++
C++101 (Part 4)
Part 4: friendship, object memory, and modern C++ — non-member non-friend, SOO/SSO, prohibiting heap, execute-around pointer, temporary proxy, nullptr, move constructor, boost mutant, deprecate and delete, function poisoning, rule of zero/three/five, most vexing parse, pass-key, and the spaceship operator.
- C++
How game GUIs get rewritten (Part 2)
The sequel: game UI architecture along six independent axes — placement relative to the world (diegetic / HUD / meta / spatial / narrative, from Metroid Prime and Dead Space to Spec Ops and Hellblade), function, in-memory storage (scene graph, flat list, immediate mode, ECS), data flow (MVC/MVVM, reactive, unidirectional), layout (constraint, flexbox, anchors, RIMD), and rendering (canvas, layer, SDF, GPU-driven). Part 2.
- C++
Why game GUIs get rewritten (Part 1)
The architecture of a game UI and why it's rewritten from project to project: a control tree as Composite, properties with reflection, decoupling from game code via bindings, prototype templates long before Unity Prefab, three handler levels, shape-based hit testing, synchronous messages, layout and 9-slice, integer coordinates, a Bridge over the renderer, styles as CSS, the pain of localization, SDF fonts, and diegetic UI (Dead Space, Doom, Metro). Part 1.
- C++
The resource manager
Why a resource manager is not a singleton but a whole engine subsystem: resource identity as a (source + parameters) pair, a cache with weak references and LRU, explicit and implicit parameters, targeted reload and hot-reload, recovery after device lost from D3D9 pools to DX12/Vulkan, a shared templated base for managers, and changing graphics settings without a restart — with examples from Unreal, Unity, Source, id Tech, Godot, No Man's Sky, and Cyberpunk.
- C++
Architectural trade-offs in game development
A big breakdown of architectural patterns and trade-offs in gamedev: layers, metalayers, subsystems, pipes & filters, microkernel, and blackboard with examples from Source, CryEngine, Unreal, id Tech, and Naughty Dog; design strategies, the push vs pull axis, scripting languages, and rethinking GoF in modern game C++.
- C++
The disobedient using
Why using namespace and ADL make name lookup in C++ unpredictable: argument-dependent lookup and operator<<, hijacking std with a local substitute, checking function viability, the ranks of implicit conversions, and why =delete functions take part in overload resolution as full-fledged candidates.
- C++
Simple name lookup in C++
Simple (unqualified) and qualified name lookup in C++: how a namespace and a local variable with the same name coexist, hiding of names and whole overload sets in inheritance, diamond-inheritance ambiguity, the using-namespace rule in qualified lookup, and the historical differences between GCC, Clang and MSVC.
- C++
Compilers get confused by names too
Name lookup in C++: identifiers, unqualified-id, qualified-id, template-id and the "terminal name", the history of ADL (Koenig lookup), two-phase lookup in templates, and why GCC, Clang and MSVC historically behaved differently.
- C++
Redundant computations
How speculative execution and branch prediction interact with the memory subsystem: why branchless code isn't always faster, the cost of a misprediction versus memory latency, binary search, and benchmarks on the Jaguar (PS4).
- C++
Myths, superstitions and folk wisdom in game development
A look at 12 common C++ gamedev "truths" — which are myths, which are superstitions, and which are folk wisdom: the cult of pure C, the "bad good build", the cost of exceptions and RTTI, smart pointers and STL containers, polymorphism, inline assembly, template bloat, premature optimization and the curse of the Friday commit.
- C++
A zoo of strings in your C++ code?
A big tour of C++ string types as a zoo of animals: char* and char[N], string literals, std::string and SSO, string_view, pmr::string, QString, NSString, std::wstring, frame strings, Unreal's FString, StringAtom and interning, COW strings and hash-based StringID — and where each fits in game engines.
- C++
The good, the bad, the colored and the fast
Abnormal memory allocators from practice: a lifetime-tracking allocator for hunting leaks, a randomizing (chaos) allocator for stress-testing long-running systems, a "colored" allocator for subsystem isolation (Deathloop), and the fast TLSF — with diagrams and a CPU-cycle benchmark.
- C++
Be your own breakpoint
How software and hardware breakpoints work: swapping a byte for int 3 (0xCC), the x86-64 debug registers DR0–DR7 and the DR7 layout, conditional, function and temporary breakpoints, a write watchpoint via GetThreadContext, a buffer canary, and a hardware-breakpoint button right in an ImGui game editor.
- C++
I reject commits that use the heap and ask colleagues to rewrite that logic
Experience building large C++ games without the heap: why dynamic allocations are dangerous on consoles and mobile (fragmentation, malloc-time degradation, a certification rejection) and what to replace them with — fixed-size containers gtl::vector<T,N>, etl/FastDelegate instead of std::function, CRTP and static polymorphism with std::variant, object pools and placement new.
- C++
Game++. Performance traps
The finale of the Game++ series: common C++ performance traps — needless allocations, treacherous RVO, a heavy std::function callback, expensive string identifiers, an approximate sine, slow integer division, the cost of cache misses, std::pair/tuple and the price of virtuality in math structures — with quick-bench benchmarks and stories from production.
- C++
Game++. while (!game(over))
Should you write your own game engine: why and whether you need to, what an engine even is and what it does — the game loop, input, graphics, assets, audio, physics, scripts and configs, networking, AI, UI and architecture (library approach, GodObject, ECS), plus tooling — with code, library links and personal experience.
- C++
Game++. Patching patterns
Design patterns in games: what survives from the GoF "blue book" and which took root specifically in gamedev — Command, State and FSM with a pushdown stack, Flyweight and instancing, Observer and EventBus, Dirty Flag, Update Layers and GOAP — with code, diagrams and use cases.
- C++
Game++. Work hard
Concurrency models in game engines: shared/separate/shadow state, workers and a thread pool, stateless workers (Assassin's Creed, Factorio), worker chains and non-blocking IO, Naughty Dog's fibers and the marl library — with diagrams, code and loading benchmarks.
- C++
Game++. Heap? Less
How games get rid of heap allocations: the five memory regions, stack vs. heap, determinism and fragmentation, RVO/NRVO, local inplace strings and pmr::string, ad-hoc polymorphism with std::variant, and real-world vector/map/string optimizations via monotonic_buffer_resource and a profiler.
- C++
Why game devs stay on C++17
Why game studios are in no rush to move to C++20: auto and a +10-15% hit to compile time, Visual Studio as the world's best debugger, the economics of build farms and tools, distrust of STL and Boost, the absence of automated tests, and why debugging doesn't scale.
- C++
Game++. Unpacking containers
Specialized containers in engines: fixed array and matrices, linear/stable/sparse/packed/static/small/dirty/buddy vector, deque and bcdeque, bounded_priority_deque, intrusive list, octree and quadtree, object_pool, ring buffer, cached_hashtable, handle_container and slot_container — how they work, diagrams and where they're used.
- C++
Game++. Building arcs
Game engine architectures and Conway's Law: the unitary (Big Ball of Mud) approach in Unity, layered in Unreal Engine, microkernel in CryEngine and O3DE, data-driven in Dagor, monolithic in X-Ray and micro-modular in Godot.
- C++
Game++. run, thread, run…
Multithreading in games: the problems with locks (deadlock, thread starvation, priority inversion in Cyberpunk 2077 and Crysis), the C++11 memory model, lock-free and atomics, spinlocks with backoff, thread pools and a task system, hitching and a read-write mutex.
- C++
Game++. Juggling STL algorithms
Why STL algorithms are "conversational" C++: they show What you do, not How; they remove bounds, empty-collection and "smeared perf" bugs. The history of EASTL, iterators and back_inserter, shader caching via set_difference and a big algorithm cheat sheet.
- C++
Game++. Dancing with allocators
A big tour of memory allocators in games: linear, step-back, frame, stack, pool, free list, arena, segregated, buddy, thread-cache, fibonacci, compacting, hot/cold splitting and TLSF — with code, diagrams and a benchmark.
- C++
Game++. Cooking vectors
How vectors work in engines and what you pay for them: capacity growth and memory fragmentation, single vs. cascaded composition, std::array, a stack-based static_vector, hybrid_vector with an SSO-like optimization, and the pitfalls of vendor pmr allocators.
- C++
Game++. String interning
String interning (string pooling) in engines: one copy of a string for every reference, literal interning in clang/GCC and why the trick breaks on Xbox, the danger of comparing with ==, fighting memory fragmentation, and a simple xstring implementation on hashes with reference counting.
- C++
How to fit an elephant into a suitcase
The levels of optimization when porting games to weak hardware: architecture, algorithms and code. A story about an expensive string-escaping check — from a naive loop to a branchless version, a lookup table and SIMD with _mm_movemask_epi8.
- C++
Spears & bits
Packing bools into bits: std::bitset, std::vector<bool>, a naive byte array and the CryEngine approach, benchmarks with spikes at 32/64/128, branch-predictor misses, and a final SSE vectorization with _mm_movemask_epi8.
- C++
Task-based thinking in game engines
The core task-system patterns in engines: moving movement, physics, scripts, path-finding, animation, rendering and I/O onto separate threads, grouping tasks, message passing, and a comparison of a simple task, a thread manager and a task manager.
- C++
The heavy H[header]
Cutting a large C++ project's build time from 15:32 to 5:16: heavy template headers, instantiation, forward declaration, precompiled headers, PIMPL, windows.h, and disabling analyzers and LTO — with header build-time tables.
- C++
Boss, it's all gone
A sequel to "Where are your bugs?": 16 Friday-night bugs from real engines — out-of-bounds writes, leaked handles on the Switch, memset on a non-trivial type, =! instead of != and alloca in a loop.
- C++
Just don't copy that
Pass-by-value vs const&, hidden allocations on strings and vectors, reserve, and a real drop to 10 FPS — all with benchmarks.
- C++
Strings in game engines
C-strings and NTBS, std::string and SSO, string_view, sized/pool/arena strings, shared strings, identifiers and SIMD parsing — how engines handle strings.
- C++
What is C++ in gamedev?
The levels C++ lives on inside an engine: hardcore number-crunching, "ordinary" C++ with scripts and hot-reload, and a meta level with RTTI, reflection and code generation.
- C++
The magic of shader swizzle in C++
Implementing swizzle (vec.xxy, vec.zx) in C++ with unions and templates — with no memory overhead and faster than glm and CxxSwizzle.
- C++
Where are your bugs?
A collection of wild bugs from real engines: a missing semicolon in Unity, a memset the compiler dropped, bitfield races in CryEngine, the most vexing parse and a dozen more.
- C++
Do names matter to the compiler
How the compiler answers two key questions — what a name means and which variant is right: name lookup and overload resolution, the coexistence of names of different categories, function/namespace/enum conflicts, and why name mangling from the 80s is behind it all.
- C++
Constraints, once again
The fundamental limits of C++ concepts: the ban on recursion in a concept definition and the inability to put a requires on the concept itself, the forms of writing requires, applying concepts to classes, methods, constructors and local variables, partial ordering and atomic constraints.
- C++
Concept hierarchies in C++
How the compiler picks among several matching template overloads via constraint subsumption and partial ordering: syntactic identity matters more than logical equivalence, the STL iterator concept hierarchy, and where deep hierarchies hurt code clarity.
- C++
A history of concepts in C++
How concepts evolved from ambitious semantic proposals of the late 1990s (reflexivity, symmetry, transitivity) and the "heavy" concepts that almost made C++11 to the pragmatic Concepts Lite model in C++20 — checking syntax instead of guaranteeing behavior.
- C++
Concepts and constraints in C++
Concepts and constraints (requires) as a replacement for SFINAE and enable_if: explicit type contracts right in the signature, requires as part of the signature, requires-expressions, simple and complex constraints and static_assert.
- C++
Overloads in C++
Overloads not as syntactic sugar but as a mechanism of generic programming: algorithm before types, exponentiation by squaring, good and bad overload sets, and a critique of the std::filesystem design.
- C++
Generalizations in C++ (part 2)
A continuation of chapter 1: object identity and equality, procedures and the call stack, calling conventions and the in/out/in-out categories, the computational basis from ENIAC to AMX, and regularity of types as a practical design guide.
- C++
Generalizations in C++ (part 1)
The published chapter 1: C++ as a way to talk about the world through entities, kinds and genera, values and their bit representation, uniqueness of representation and equality, pure (regular) functions, and objects as a contract between programmer, compiler and machine.
- C++
Generalizations, Values, and Objects in C++
Entities, kinds and genera, values and their representation, objects, procedures, the computational basis, and regularity — the language's foundation.
- C++
No need to rush… (On spinlocks)
Spinlock implementations — from naive TAS to a ticket spinlock — with benchmarks, cache misses, and thread-prioritization nuances.
- C++
Cache pollution? Stock up on tests
How cache, associativity, coherence, and data alignment affect performance — with benchmarks.
- C++
A C++ enum's name at runtime
Getting a type's and an enum value's name at runtime without RTTI — via __PRETTY_FUNCTION__, templates, and constexpr magic.
- C++
When it's private but you really want public
Testing private members of a C++ class without editing headers: from friends and #define private public to a template hack.
- C++
Why are there three different sin in the Switch SDK?
How porting games surfaced three sin implementations — and what the disassembly showed for different optimization levels.