C++ programming Bjarne Stroustrup with modern AI
- Bryan Downing
- 2 days ago
- 4 min read
C++ programming Bjarne Stroustrup with modern AIBjarne Stroustrup on Modern C++: Writing Better Code in the 21st Century
At this year's Qt World Summit in Munich, C++ creator Bjarne Stroustrup delivered a compelling presentation on "21st Century C++," offering insights into modern C++ programming practices. I spoke with him before his talk to discuss his perspective on contemporary C++ development. This is all about C++ programming Bjarne Stroustrup.

The Evolution of Modern C++
Rather than focusing solely on upcoming C++26 features like reflection and contracts, Stroustrup emphasized the cohesive nature of the language as it exists today. "The language is not just the latest features," he explained. "Contemporary C++ requires using elements from both its earliest days and modern times. My main point isn't about chasing new features—it's about utilizing the language as it stands now. Today's C++ is more coherent, efficient, expressive, and safer."
Essential Features for Modern C++ Development
When asked about the must-use features for modern C++ programming, Stroustrup highlighted how different elements work together synergistically. "I focus on expressing things more directly in the language," he said. "For instance, with modern loops, you don't need loop variables for most container iterations. You can simply write 'for x in y' to state your intent directly. This approach is not only easier for compilers to optimize but reduces opportunities for programmer error while requiring less code."
Stroustrup also emphasized the importance of generic programming, noting that "types are usually deduced automatically, ensuring you always get the correct type."
Resource management stands as another critical aspect. "Using RAII guarantees resources are properly deleted or closed. Every resource should be owned by a handle within a specific scope, which eliminates many potential leaks."
Practices to Avoid in Modern C++
Stroustrup was clear about anti-patterns: "Never use raw pointers as resource handles—that violates everything I've advocated for. Never pass elements via single raw pointers to arrays, as you lose information about the number of elements, making proper range checking impossible. With vectors, you always know the element count and types."
"I rarely use casts anymore, which relates to proper generic programming. Avoiding casts prevents numerous type errors," he added.
He also addressed better function return strategies: "Traditionally, you'd allocate something on the heap and return a pointer, creating the burden of eventual deletion. Today, you can simply move a vector out, usually with zero cost."
Language Features Worth Embracing
During his presentation, Stroustrup advocated for modules with import statements rather than traditional #include directives. The latter introduces problems: they're transitive (order-dependent), cause repetitive compilation, and can introduce subtle bugs. In contrast, import isn't transitive and enables one-time compilation of many elements.
He also highlighted templates and concepts (mandatory since C++20), stating, "Using concepts is actually easier than not using them." Notably, Stroustrup mentioned that his production code doesn't utilize "anything more advanced than what's covered in this talk," and he hasn't encountered resource leaks after basic testing "for years."
Enforcing Modern C++ Practices
When asked about enforcing modern programming styles, Stroustrup acknowledged this challenge. "Following guidelines consistently in large codebases is nearly impossible without support tools. I'm developing 'profiles' that enforce specific sets of guarantees."
He dismissed the idea of removing "dangerous, complicated elements" from C++ itself, despite frequent requests for simplified versions. "The challenging elements—pointers, arrays, casts—are necessary for implementing good abstractions. The solution is removing them from application code while retaining them for implementing abstractions. Operators new and delete, for instance, shouldn't appear in application code."
Stroustrup expressed disappointment that profile support won't be included in C++26: "Unfortunately, the standards committee got confused and didn't ensure this for C++26." In the meantime, he recommends tools like Clang-Tidy, which implements partial checking for the C++ Core Guidelines—a collaborative project involving Red Hat, Microsoft, and others.
AI and New Languages
Regarding AI's impact on C++ development, Stroustrup expressed concern: "While AI can help, it tends to guide programmers toward common but potentially outdated practices. I worry people may lose their ability to identify problems when they become too dependent on AI assistance."
On the subject of emerging languages like Google's Carbon project, Stroustrup was pragmatic: "Creating something better than C++ for specific domains is relatively easy, but C++'s strength lies in its versatility across diverse domains." He cautioned that successful new languages must interact with established ones like C++ and Python, warning: "Without careful consideration, instead of having one arguably large language like C++, we could end up with ten insufficient languages all struggling to interoperate."
C++ Evolution and Implementation
When asked if C++ evolves too slowly, Stroustrup offered a balanced view: "When half the people complain you're moving too slowly, and the other half say you're moving too fast, you're probably at the right pace. I would personally prefer slightly faster progress than the Standards Committee allows, but there are likely more C++ developers who think it's already moving too quickly."
Regarding implementation variations across compilers, Stroustrup acknowledged the friction but highlighted benefits: "Each major compiler—and even many embedded ones—has more users than most entire languages possess. I'm wary of monocultures; historically, they're vulnerable to single points of failure. Multiple implementations create healthy competition and innovation space, even if they're not perfectly identical." He noted that major C++ compilers are "increasingly aligned," adding, "It's worth remembering that there has never been a fully compliant C compiler—and likely never will be."