C++, Complexity, and Compiler Bugs
Azeem Bande-Ali discusses C++ complexities, highlighting issues like temporary lifetime extension, C and C++ incompatibilities, and template disambiguation, while advocating for a simpler successor language to enhance development.
Read original articleAzeem Bande-Ali discusses the complexities of C++ and the challenges posed by compiler bugs based on his professional experiences. He highlights how the language's power comes with significant emergent complexity, making it difficult for developers to fully grasp. One key issue he encountered was related to temporary lifetime extension, where a const reference could extend the lifetime of a temporary variable, leading to unexpected behavior when upgrading compilers. This feature, established in 1993, was not widely known among developers, which resulted in production crashes. Bande-Ali also addresses the incompatibility between C and C++ regarding designated initializers, where GCC7 would silently ignore invalid syntax, causing years of unnoticed errors until GCC9 flagged them. Additionally, he points out the confusion surrounding template disambiguation, where different compilers (GCC and Clang) handle unnecessary disambiguation differently, complicating the development process. He concludes by expressing a desire for a successor language that could simplify C++'s complexities while still allowing for its powerful features.
- C++'s complexity can lead to significant challenges for developers, especially with compiler bugs.
- Temporary lifetime extension can cause unexpected behavior when upgrading compilers.
- Incompatibilities between C and C++ can lead to unnoticed errors in code.
- Template disambiguation issues arise from differing compiler interpretations.
- There is a call for a simpler successor language to address C++'s complexities.
Related
C Isn't a Programming Language Anymore (2022)
The article examines the shift in perception of C from a programming language to a protocol, highlighting challenges it poses for interoperability with modern languages like Rust and Swift.
Clang vs. Clang
The blog post critiques compiler optimizations in Clang, arguing they often introduce bugs and security vulnerabilities, diminish performance gains, and create timing channels, urging a reevaluation of current practices.
Lesser known tricks, quirks and features of C
The article explores lesser-known C programming features, including the comma operator, designated initializers, compound literals, and advanced topics like volatile qualifiers and flexible array members, highlighting their potential pitfalls.
Lessons learned from a successful Rust rewrite
The transition from C++ to Rust improved code performance and safety but revealed challenges like undefined behavior, memory management issues, and tooling limitations, highlighting the need for a stable ABI.
Speculations on arenas and custom strings in C++
The author explores arena allocation and custom strings in C++, aiming to simplify complexity by minimizing advanced features. Challenges with static initialization are noted, with proposed workarounds for compile-time construction.
Specifically,
- incompatibility with C is just stupid
- agreeing with sibling comment, references were a mistake
- the complexity has really gotten out of hand.
I feel exactly like the author. I get less comfortable with C++ year after year, despite writing it all day. I feel like a race car driver who was once confident but has now gotten into too many big crashes.
2 cents from gamedev:
1. Vendor lock in on platforms is still there and is not going anywhere.
2. Existing code. Every successful AAA project / game engine has a mountain of code that is already there. Often with even bigger mountain of data that no one really wants to redo. It also often depends on multiple middleware or open source packages that already work and are hard to replace.
There is no rational reason to keep learning historical accidents why things are like they are in C++ but see points 1 and 2 above.
> I am hoping there can be a cleaner successor language that lets you easily use C++ code when you need to but also allows you to ignore the C++ complexity when you aren’t touching the C++ code directly.
I do not understand how left hand of author wants to run C++ code with all of the data going in and right hand does not want to touch it. It does not work like this. At least in gamedev. End of rant.
Related
C Isn't a Programming Language Anymore (2022)
The article examines the shift in perception of C from a programming language to a protocol, highlighting challenges it poses for interoperability with modern languages like Rust and Swift.
Clang vs. Clang
The blog post critiques compiler optimizations in Clang, arguing they often introduce bugs and security vulnerabilities, diminish performance gains, and create timing channels, urging a reevaluation of current practices.
Lesser known tricks, quirks and features of C
The article explores lesser-known C programming features, including the comma operator, designated initializers, compound literals, and advanced topics like volatile qualifiers and flexible array members, highlighting their potential pitfalls.
Lessons learned from a successful Rust rewrite
The transition from C++ to Rust improved code performance and safety but revealed challenges like undefined behavior, memory management issues, and tooling limitations, highlighting the need for a stable ABI.
Speculations on arenas and custom strings in C++
The author explores arena allocation and custom strings in C++, aiming to simplify complexity by minimizing advanced features. Challenges with static initialization are noted, with proposed workarounds for compile-time construction.