Interview: Bjarne Stroustrup on 21st Century C++, AI Risks, and Language Evolution
C++ inventor Bjarne Stroustrup spoke with DevClass about modern C++ coding practices, the challenges of replacing the language, the risks associated with AI, and the benefits of having multiple compilers with slightly different implementations.

The interview took place at the Qt World Summit in Munich, prior to Stroustrup’s presentation on “21st century C++”.
The Essence of Modern C++
Stroustrup clarified that his focus isn't solely on the latest features in C++ 26, such as reflection and contracts. He emphasized that modern C++ is about leveraging a combination of features from the language's entire history. The goal is to use the language as a cohesive, efficient, expressive, and safe tool.
Key Features for Modern C++ Programming
Stroustrup highlighted several features that are crucial for modern C++:
- Direct Expression: Aim to express operations directly in the language. For example, using range-based for loops (
for x in y
) to iterate over containers, which simplifies code, enhances compiler optimization, and reduces errors. - Generic Programming: Utilize generic programming to ensure type correctness through type deduction.
- Resource Management: Implement robust resource management by ensuring every resource is owned by a handle within a specific scope, preventing leaks.
Practices to Avoid in Modern C++
Stroustrup also outlined practices that modern C++ developers should avoid:
- Raw Pointers as Resource Handles: Avoid using raw pointers to manage resources, as this violates resource management principles.
- Passing Elements via Raw Pointers: Do not pass a set of elements using a single raw pointer, as it lacks information about the number of elements and prevents proper range checking. Use containers like
std::vector
instead. - Excessive Casting: Minimize the use of casts to reduce type errors, leveraging generic programming to avoid them.
- Dynamic Allocation for Return Values: Avoid allocating memory on the free store to return values from functions. Instead, move vectors, which is typically a zero-cost operation.
Leveraging Modules, Templates, and Concepts
Stroustrup advocated for the use of modules with import statements over the traditional #include
. Modules offer benefits such as non-transitive inclusion, reduced compilation times, and fewer subtle bugs. He also emphasized the importance of templates and concepts (introduced in C++20), stating that using concepts makes programming easier.
He mentioned that his production code does not use anything more advanced than what he presented, and he has not encountered resource leaks after basic testing for many years.
Enforcing Modern C++ Style
Enforcing a modern C++ style in large codebases is challenging. Stroustrup is working on guidelines enforced by profiles, which specify a set of guarantees to be enforced by the compiler. However, he expressed frustration that the C++ standards committee did not guarantee the inclusion of this feature in C++26.
In the meantime, developers can use tools like Clang-Tidy, which checks for compliance with the C++ core guidelines developed in collaboration with Red Hat, Microsoft, and others.
Concerns About AI's Impact on Coding
Stroustrup expressed concerns about the impact of AI on C++ coding. While AI can be helpful, it may guide developers towards outdated practices and reduce their ability to detect problems independently.
The Emergence of New Languages
Regarding new languages like Google’s Carbon, Stroustrup noted that while it’s easy to design a language that is better than C++ for a specific domain, C++’s strength lies in its versatility across diverse domains. He cautioned that if new languages succeed, they must interoperate with C++, Python, and others. Otherwise, the industry risks ending up with multiple insufficient languages struggling to interoperate.
The Pace of C++ Evolution
When asked if C++ evolves too slowly, Stroustrup responded that the pace is likely right if half the people complain it’s too slow and the other half complain it’s too fast. He admitted that he would like the Standards Committee to move faster but acknowledged that the committee's size and diverse concerns slow things down. However, many C++ developers likely believe it is moving too fast.
Compiler Variations and Monocultures
Stroustrup addressed the variations in implementations among C++ compilers, noting that each major compiler has a large user base. He expressed his dislike for monocultures, stating that historical monocultures are vulnerable to bugs or poisons. While the implementations in major C++ compilers are not identical, they are close and converging. The existence of multiple compilers fosters competition, innovation, and diversity. He also noted that there has never been a fully compliant C compiler.
Key Takeaways
- Modern C++ is Cohesive: It leverages features from the language's entire history for efficiency and safety.
- Avoid Outdated Practices: Steer clear of raw pointers for resource management and excessive casting.
- Embrace Modern Features: Utilize modules, templates, and concepts to write cleaner and more efficient code.
- AI Concerns: Be cautious of AI's impact on coding practices and maintain independent problem-solving skills.
- Language Diversity: Recognize the strengths and challenges of C++ in a diverse technological landscape.
- Compiler Diversity: Appreciate the benefits of having multiple C++ compiler implementations for competition and innovation.