The programming language C++ will turn 38 years old in 2023, yet remains highly popular, having recently been recognized as the fastest growing programming language (opens in new tab) since the Covid-19 pandemic.
The age of the language primarily poses two major problems: it is saddled with technical debt, and is regularly criticized for missing features and simply being unintuitive. It has also had time to become so embedded that getting programmers to accept an alternative en-masse is an uphill battle.
Enter Google, and Carbon, a programming language it first unveiled in July 2022 that it hopes will wipe away technical debt by starting over and allowing developers to merge their own features via GitHub (opens in new tab). It also wants to offer a compelling reason for developers to gradually switch to it by being interoperable with C++ code, rather than gunning for its crown.
TechRadar Pro had the opportunity to speak with Phil Nash, Developer Advocate at “clean code environment” software provider Sonar, the author of the C++ test framework, about what Carbon aims to do and how it intends to do it.
Is Carbon being developed as a replacement for C++?
Not exactly. The Carbon programming language is not technically a replacement for C++. Instead, it is designed as a successor. That may seem like splitting hairs. But the distinction is important: Carbon is intended to be used alongside C++. The interop story is essential as it allows you to keep your investment in years, maybe decades, of legacy code and third-party libraries.
What problems is Carbon intended to solve?
C++ has a reputation for being a complex and hard to use language – full of pitfalls and gotchas.
There are several significant issues in C++ that Carbon addresses. These problems in C++ are the result of decades of technical debt in the language that, because of the priorities of C++ evolution, cannot be addressed within C++ itself.
The language is notoriously hard to parse – even for tools – and often requires many extra keywords to get the behavior you would like by default. Its original take on generics evolved into a fully fledged meta-programming language, yet had been unable to fulfill some of its early goals.
Carbon also aims to address the governance model: favoring a Benevolent Dictators (emphasis on the plural) model with an open evolution process on modern tools – rather than an international standard (ISO) that is optimized for representation by nations and corporations.
Built into the evolution model is the expectation of breaking change – and a tool-based approach to dealing with it.
How does Carbon’s Benevolent Dictators / open evolution model work?
Rather than a BDFL (Benevolent Dictator For Life) model, the governance team (of three people) will periodically be changed.
The evolution process occurs in public using familiar tools, such as GitHub and Discourse and is open to external contributors.
Why is this model inherently better than an international standard?
ISO participation is heavily biased towards those whose employers have a vested interest in a particular direction of language evolution – although this depends on the country.
The closed nature of the process can lead to a disconnect between the committee and the community – and lead to accusations of misplaced motives. However, on the flip side, that same closed process model does provide a neutral ground for employees from competing organizations collaborating towards a common goal.
How else does Carbon differ from C++?
A cleaner, simpler, syntax that is safer by default. It is also easier to parse – and therefore easier to write effective tools for (including those tools to help migrate after breaking changes to the language).
Are there any other languages designed as a successor to C++?
The other major successor announced so far is Herb Sutter’s Cpp2. Another language of note is Circle – although this is pitched more as a C++-with-extras – a playground of ideas that could go into C++ itself.
What are the key differences between these other successors and Carbon?
Cpp2 compiles down to C++. More specifically it compiles down to readable C++. This is important because, in theory, it means that if you decide to abandon Cpp2 you can take the generated C++ and just carry on as if it was always written that way.
It is also being designed in tandem with major proposals for equivalent features in C++. If any of these are adopted the difference between the languages gets smaller.
What has to happen for Carbon to be successful – and how likely is that?
Enough of the community would need to commit to it for it to be worthwhile, and enough contributors need to commit their time to keep it evolving.
For many Carbon may not be taken seriously while it is largely seen as under the control of Google, so the future of the leadership team is a big factor, too. With other contenders, like Cpp2, also emerging it has a good chance, but is by no means guaranteed.
With the launch of Carbon (and other successors), how do you think C++ will change and evolve?
This has intensified interest in ways of simplifying the language. Ideas from Carbon – and Cpp2 – will likely inspire the future direction of C++ – just as ideas from Rust and Circle already have. C++ is not going away any time soon.