21st Century C++ (Feb. 2025) by Bjarne Stroustrup
C++ has evolved significantly, yet many developers use outdated practices. Bjarne Stroustrup advocates for modern features like RAII to improve code efficiency, safety, and maintainability through cohesive programming practices.
Read original articleC++ has evolved significantly since its inception over 45 years ago, yet many developers still use outdated practices that hinder performance and maintainability. Bjarne Stroustrup emphasizes the importance of adopting contemporary C++ features to enhance code expressiveness, type safety, and efficiency. Key concepts for modern C++ programming include resource management, lifetime control, error handling, modularity, and generic programming. Stroustrup advocates for the use of modern C++ techniques, such as RAII (Resource Acquisition Is Initialization), which ensures that resources are automatically released when they go out of scope, thus preventing leaks. He also highlights the importance of using the language's features cohesively to solve problems effectively. The article discusses various C++ features, both old and new, that contribute to better programming practices, including constructors, destructors, templates, modules, and concurrency support. Stroustrup concludes by stressing the need for guidelines and enforcement mechanisms to ensure that developers utilize C++ in a way that aligns with 21st-century standards, ultimately leading to more robust and maintainable software.
- C++ has evolved, but many developers still use outdated practices.
- Modern C++ features enhance code expressiveness, type safety, and efficiency.
- RAII is crucial for effective resource management and preventing leaks.
- A cohesive use of C++ features is essential for solving programming problems.
- Guidelines are needed to ensure adherence to contemporary C++ standards.
Related
The Two Factions of C++
C++ faces internal conflict between modern tech companies and legacy systems, with concerns over its evolution, safety issues raised by the U.S. government, and a growing shift towards Rust.
C has its limits. If you know where to look
The article highlights the evolution of C programming, focusing on data type portability challenges, the standardization through ANSI-C and stdint.h, and the importance of staying updated with programming developments.
C++ is an absolute blast
C++ has gained popularity due to its evolution since C++11, enhancing usability and creativity. It remains versatile for various applications while avoiding the complications of more fashionable languages.
Welcome Back to C++(2022)
C++ has evolved into a versatile programming language emphasizing performance and flexibility, with modern features enhancing safety, including smart pointers, standard library containers, move semantics, and improved error management.
21st Century C++
Bjarne Stroustrup discusses C++'s 45-year evolution, urging developers to adopt modern practices for improved performance and maintainability, while providing guidelines and examples for effective coding techniques.
- Many developers express challenges with outdated code and the complexities of modern C++ features.
- There is a common sentiment about the cumbersome nature of header files and the language's overall complexity.
- Some commenters highlight the need for better tooling and enforcement of guidelines to improve code safety and efficiency.
- Several users share their experiences transitioning to other languages, indicating a struggle to keep up with C++ advancements.
- There is appreciation for Bjarne Stroustrup's ongoing contributions to the language, though skepticism remains about its future improvements.
The moral of the story? Backwards compatibility means never leaving your baggage behind.
C++ may offer modules (in fact, it's been offering them since 2020), however, when it comes to their implementation in mainstream C++ compilers, only now things are becoming sort of usable with modules still being a challenge in more complex projects due to compiler bugs in the corner cases.
I think we need to be honest and upfront about this. I've talked to quite a few people who have tried to use modules but were unpleasantly surprised by how rough the experience was.
When the heck that day will actually arrive, FSM only knows. The will is sort-of there, but there are just SO many other things competing for my time and attention. :-(
[1]: funny side story about that. For anybody too young to remember just how hot the job market was back then... one day I was sitting stopped at a traffic light in Durham (NC). I'm just minding my own business, waiting for the light to change, when I catch a glimpse out of my side mirror, of somebody on foot, running towards my car. The guy gets right up to my car, and I think I had my window down already anyway. Anyway, the guy gets up to me, panting and out of breath from the run and he's like "Hey, I noticed your license plate and was wondering if you were looking for a new job." About then the light turned green in my direction, and I'm sitting there for a second in just stunned disbelief. This guy got out of his car, ran a few car lengths, to approach a stranger in traffic, to try to recruit him. I wasn't going to sit there and have a conversation with horns honking all around me, so I just yelled "sorry man" and drove off. One of the weirder experiences of my life.
"a simple program that writes every unique line from input to output"
Bjarne does thank more than half a dozen people, including other WG21 members, for reviewing this paper, maybe none of them read this program?
More likely, like Bjarne they didn't notice that this program has Undefined Behaviour for some inputs and that in the real world it doesn't quite do what's advertised.
As a C++ newbie I just don't understand the recommended path I'm supposed to follow, though. It seems to be a mix of "a book of guidelines" and "a package that shows you how you should be using those guidelines via implementation of their principles".
After some digging it looks like the guidebook is the "C++ Core Guidelines":
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines
And I'm supposed to read that and then:
> use parts of the standard library and add a tiny library to make use of the guidelines convenient and efficient (the Guidelines Support Library, GSL).
Which seems to be this (at least Microsoft's implementation):
https://github.com/microsoft/GSL
And I'm left wondering, is this just how C++ is? Can't the language provide tooling for me to better adhere to its guidelines, bake in "blessed" features and deprecate what Bjarne calls, "the use of low-level, inefficient, and error-prone features"? I feel like these are tooling-level issues that compilers and linters and updated language versions could do more to solve.
(I must say that I was happy to see/read that article, though)
Bjarne Stroustrup, AT&T Labs, Florham Park, NJ, USA
Abstract
This paper outlines the proposal for generalizing the overloading rules for Standard C++ that is expected to become part of the next revision of the standard. The focus is on general ideas rather than technical details (which can be found in AT&T Labs Technical Report no. 42, April 1, 1998).
Over my career I’ve written hundreds of thousands of lines of it.
But keeping up with it is time consuming and more and more I find myself reaching for other languages.
Whenever I have an idea and I start a project, I start with C++ because I know if the idea works out, the project can grow and work 10 years later.
Until then... YAWN.
If the uber-bean counter, herald of the language of bean counters demonstrate unwillingness to count beans, maybe the beans are better counted in another way.
For whatever reason this is probably the biggest reason I've struggled with it( aside from tooling... Makes me miss npm).
Opening braces should be inline with the expression or definition.
Comments can be above what they're referred to.
Combined, this makes any code snippet look like crap on mobile and almost impossible to follow as a result.
Related
The Two Factions of C++
C++ faces internal conflict between modern tech companies and legacy systems, with concerns over its evolution, safety issues raised by the U.S. government, and a growing shift towards Rust.
C has its limits. If you know where to look
The article highlights the evolution of C programming, focusing on data type portability challenges, the standardization through ANSI-C and stdint.h, and the importance of staying updated with programming developments.
C++ is an absolute blast
C++ has gained popularity due to its evolution since C++11, enhancing usability and creativity. It remains versatile for various applications while avoiding the complications of more fashionable languages.
Welcome Back to C++(2022)
C++ has evolved into a versatile programming language emphasizing performance and flexibility, with modern features enhancing safety, including smart pointers, standard library containers, move semantics, and improved error management.
21st Century C++
Bjarne Stroustrup discusses C++'s 45-year evolution, urging developers to adopt modern practices for improved performance and maintainability, while providing guidelines and examples for effective coding techniques.