Skip to main content

Google’s Carbon programming language aims to replace C++


Is C++ in need of a replacement? Yes, it is - but the problem is that there is a lot of it about. Today there are just too many ways of doing anything with C++ and too many ways to make C++ look like your own personal language. Now a group of Google engineers has got together to see if their latest project, Carbon, can do something about the problem.

At the C++ North event underway in Toronto this week, Google software engineer Chandler Carruth presented the Carbon Language, described as an “experimental successor to C++”, evoking high interest in the C++ community.

“We understand the community interest in this keynote. We will post the recording on an accelerated schedule,” said the conference organizers on Twitter. Carruth is technical lead for Google’s core programming languages and language evolution, represents Google on the C++ Standards Committee, and is a contributor to LLVM and Clang.

Google has a reputation for inventing, or just making use of, languages that are extensions to existing languages. Dart for JavaScript, Go for C and Kotlin for Java. Of course, we have Rust as a proposed alternative to C and C++, but this isn't really an extension language - it's more a complete, let's-start-over, language. Carbon is trying to be like Rust while remaining compatible with the C++ world.

Here is a sample of Carbon:



The Carbon developers explain that while C++ is the “dominant language for performance-critical software,” its legacy and technical debt means that “incrementally improving C++ is extremely difficult.”

One solution is to migrate to other languages such as Rust, Kotlin, Swift or Go, but these languages are hard to migrate to, and in some cases have performance overhead. Carbon is a new language that aims to match the performance of C++ and maintain “seamless bidirectional interoperability,” as well as a gentle learning curve for C++ developers.

Why is C++ hard to improve? C++ itself started as a fork of C, and the C language is 50 years old, so it is not surprising that there is a lot of legacy. According to the Carbon team, the C++ designers have added rather than replaced language features over time, creating complex feature interactions. Preserving binary compatibility is another legacy problem. In addition, the C++ committee and evolution process is “oriented around standardization rather than design”, is slow and sometimes fails to make decisions.

Carbon is an effort to side-step these problems with a new approach based on open source principles. “We will even try to close a huge gap in the C++ ecosystem with a built-in package manager,” state the documents. The current roadmap aims to complete version 0.1 of the language this year, 0.2 in 2023, and version 1.0 in 2024 or 2025.



Memory safety is an important consideration but is not the initial goal. “The difference between Rust’s approach and Carbon’s is that Rust starts with safety and Carbon starts with migration,” say the docs. The approach is to simplify the language in order to “create space for safety features,” and then to “re-engineer foundations to model and enforce safety.”

Will Carbon ignite?

Who knows as it isn't the first attempt at replacing or extending C++.

We will have to see if some time and development pressure manages to turn Carbon into the diamond we are looking for.

That's it for this blog. Hope you got to know about the Carbon programming language. Keep learning.

Comments