Orthodox C++
This article passionately advocates for "Orthodox C++," a minimalist subset of the language that prioritizes simplicity and C-like conventions over the complexities of Modern C++. It argues that newer features like exceptions, RTTI, and advanced STL often introduce unnecessary complexity and hidden costs. Hacker News readers often appreciate discussions that challenge conventional wisdom and promote pragmatic, performance-oriented development practices, making this deep dive into C++ philosophy particularly resonant.
The Lowdown
The article "Orthodox C++" introduces a philosophy for C++ development that advocates for a highly constrained, C-like subset of the language. Authored by Branimir Karadžić, this approach, sometimes dubbed "C+", stands in stark contrast to "Modern C++" by intentionally avoiding many contemporary features in favor of simplicity, clarity, and broader compatibility.
- Definition: Orthodox C++ is a minimal C++ subset designed to improve upon C while deliberately omitting features considered "unnecessary" or problematic in Modern C++.
- Critique of Modern C++: The author contends that many newer C++ features, such as RTTI, exceptions, and C++ standard library streams, have historically led to unforeseen complexities, performance issues, or simply proved to be less beneficial than initially perceived.
- Benefits of Orthodox C++: Adopting this limited subset results in code that is easier to understand, simpler to maintain, compatible with older compilers, and more readily integrated into other C++ projects due to its reduced feature footprint.
- Feature Avoidance: Specific recommendations include sticking to C-like conventions (e.g., printf over iostream, <stdio.h> over <cstdio>), avoiding exceptions and RTTI, and being cautious with STL features that allocate memory.
- Metaprogramming & New Standards: The author advises against excessive metaprogramming and suggests a cautious approach to new C++ standard features, recommending a waiting period of several years for features to mature and gain widespread, stable compiler support. Modules, in particular, are strongly advised against due to portability and complexity concerns.
- Real-world Examples: The article cites several high-profile projects, including DOOM 3 BFG, dear imgui, and Qt (when built with specific flags), as practical implementations of the Orthodox C++ philosophy.
Ultimately, "Orthodox C++" is presented not just as a coding style but as a robust methodology for building performant, maintainable, and broadly compatible C++ applications, particularly emphasizing the practical lessons learned from years of development experience.