Modern C++ Techniques for Legacy Code: An Emulator Case Study | ACCU 2025 Keynote

Added:

Orthodox C++ and the Case Against Modern C++ Complexity in Systems Programming

While modern C++ features like templates, coroutines, and modules offer powerful abstractions, a significant school of thought within systems and emulator programming—often referred to as 'Orthodox C++' or minimalist C++—argues against their adoption. Proponents of this view contend that modern C++ introduces excessive cognitive load, severely degrades compilation times, and leads to binary bloat. For low-level emulation, where precise hardware control and predictability are paramount, critics argue that relying on complex language features can obscure runtime performance and complicate debugging. Instead, they advocate for a simpler, 'C-style' subset of C++ that prioritizes straightforward data-oriented design, explicit memory management, and minimal abstraction. This ensures the code remains highly performant, portable, and accessible to a broader range of developers without requiring cutting-edge compiler and toolchain support.

Fundamental understanding of C++11/14 features such as move semantics, smart pointers, and basic templates.
Basic concepts of computer architecture and emulation, including registers, memory mapping, and instruction cycles (specifically regarding 8-bit CPUs like the Z80).
Familiarity with compile-time evaluation concepts, specifically the basic usage of the 'constexpr' keyword.
Understanding the differences between legacy C-style programming (manual memory management, raw pointers) and idiomatic C++.
Advanced C++ Coroutines: Implementing custom coroutine types, promise objects, and awaitables for asynchronous systems.
C++20 Modules Migration: Practical strategies for refactoring large legacy headers into modular, scalable translation units.
Compile-time Metaprogramming: Utilizing 'consteval', 'constinit', and template metaprogramming to perform complex computations and validation at compile time.
Micro-architectural Performance Profiling: Analyzing compiler output (e.g., via Compiler Explorer) and assembly to verify that modern abstractions yield zero-overhead machine code.
25.1K views864likes1:20:45@ACCUConfOriginal Release: 2025-08-29

This keynote demonstrates how modern C++ features like templates, modules, and coroutines can be applied to traditional systems programming tasks, such as implementing a ZX Spectrum emulator. The presenter, an experienced C++ developer who initially resisted modern language features, shows that while these features can improve code quality and maintainability, they also present challenges including increased build times and steeper learning curves. The key takeaway is that learning new programming paradigms, even for experienced developers, is essential for professional growth and can lead to more elegant and maintainable code solutions.