New promising programming languages are popping up constantly. Some do rather successfully – take Rust and Go as popular success stories. And yet, despite the excitement around new languages, it’s still the tried and true older languages that rank at the top of survey lists when it comes to what is most in use: Java, C, C++ and Python. However, those popular languages aren’t without their flaws.
In a talk at CppNorth in July 2022, Chandler Carruth, principal software engineer at Google, announced the development of Carbon, which is intended as a successor language to C++. According to Google, while C++ is “the dominant programming language for performance-critical software,” it is difficult to make improvements after decades of accruing technical debt and a challenging evolution process.
In addition to decades of its own technical debt, Google also noted in the Carbon GitHub page that when C++ was created it also inherited some of the issues from C, such as textual preprocessing and inclusion.
“At the time, this was essential to C++’s success by giving it instant and high quality access to a large C ecosystem. However, over time this has resulted in significant technical debt ranging from integer promotion rules to complex syntax with ‘the most vexing parse,’” Google wrote.
Carruth explained in his talk that taking on this technical debt was an excellent decision at the time and was probably “the right call.” It allowed C++’s ecosystem to be bootstrapped and that was essential to its success, he said.
One of the other things that adds to the technical debt is C++’s commitment to backwards compatibility, Carruth explained. Backwards compatibility also makes it difficult or impossible to fix technical debt that already exists.
“C++ has been with us for 40… or even 50 years (if we count compatibility with C), so it’s natural that the language has built a lot of ‘waste,’ especially since we want to be backward compatible,” said Bartlomiej Filipek, a C++ programmer, author and blogger.
Rust is a successor to C++, not a replacement
Google believes the best option for avoiding inheriting C or C++’s problems is to build a new language that uses modern language foundations, such as a modern generics system, modular code organization, and consistent and simple syntax.
Google is following the successor language approach with Carbon. According to Carruth, there are a few qualities a successor language needs to have. It should build on an existing ecosystem, provide bi-directional interoperability, optimize the learning curve and adoption path, and have tool-assisted migration support.
Other successor languages like Kotlin (a successor to Java) and TypeScript (a successor to JavaScript) have been quite successful at filling gaps in their respective programming language ecosystems.
Rust is a popular language that competes with C++ on performance, but it is a replacement, not a successor, meaning it is basically a separate language, explained Phil Nash, developer advocate at SonarSource.
“Rust is a great programming language and if Rust actually solves your problem, if it’s a good tool for you to use, please use it,” Carruth said. “It’s a fantastic programming language and I’m super impressed by everything that the Rust team and Rust community are doing. But if you have a very large C++ ecosystem and you have very deep dependencies, then moving that to Rust is going to be extremely difficult.”
Carbon, on the other hand, is designed to interoperate seamlessly with C++ code. According to Filipek, this is beneficial to C++ developers because it means they can start using Carbon without having to start from scratch.
“You can have a project that has lots of C++ code, and maybe you’ve been maintaining it for 20 or 30 years, and you can just start introducing Carbon code right alongside it and they can call each other seamlessly. So you don’t have to just invest everything into some new ecosystem,” said Nash.
According to the project’s GitHub page, there are several requirements for a successor language to C++. These include matching the performance of C++, bidirectional interoperability with C++, a gentle learning curve, comparable expressivity, and scalable migration.
Because Carbon is being developed as a successor language, its success won’t mean the extinction of C++. “It might mean that we can build better, safer, and easier-to-develop systems that rely on or reuse existing (C++) parts. And as always, both sides: C++ and Carbon, will learn from each other and improve along the way,” said Filipek.
What will Carbon look like in the C++ ecosystem?
As it was only just announced over the summer, the language is still in its early days, so it’s difficult to predict how successful it will be. It’s currently listed as “experimental” on the GitHub page, and has no existing compiler or toolchain yet.
However, at the time of this writing, Google has already decided on a number of core aspects of the project. These include the strategy of the project; that it will have an open-source project structure, governance model, and evolution process; designs for critical aspects of the language, such as generics, class types, inheritance, operator overloading, lexical and syntactic structure, and code organization and modular structure; and a prototype interpreter demo.
“While it will sound like a great idea, there’s a number of reservations that people have,” Nash said. “In particular, there’s a sense that this is a Google thing and that this is just Google trying to push their view of things on the world. And that there’s some truth to that, to be fair.”
What Nash is referring to is the fact that the initial governance team is composed of Google employees and that the project is being funded by Google.
However, during the 45 minute talk that Carruth gave and the following Q&A that he did with fellow governance team members Kate Gregory and Richard Smith, a lot of time was spent talking about the open nature of the project and the thought that went into decisions like choosing a governance structure.
“When we’re changing things, people need to understand how and why we’re making changes,” said Carruth. “What went into it, what factors we’re considering, how can they participate? That has to be open. That has to be transparent.”