Carbon, the latest programming language to be built within Google, was unveiled today as an experimental successor to C++.

Over the years, Google has created a few programming languages, some of which have become more popular and prominent than others. For example, Golang (or simply Go) was created for the purpose of improving the development of servers and distributed systems and has since been adopted by the public. Meanwhile, the Dart programming language, originally intended as something of an alternative to JavaScript, didn’t reach mainstream popularity until the release of Flutter.

Why build Carbon?

C++ remains the dominant programming language for performance-critical software, with massive and growing codebases and investments. However, it is struggling to improve and meet developers' needs, as outlined above, in no small part due to accumulating decades of technical debt. Incrementally improving C++ is extremely difficult, both due to the technical debt itself and challenges with its evolution process. The best way to address these problems is to avoid inheriting the legacy of C or C++ directly, and instead start with solid language foundations like modern generics system, modular code organization, and consistent, simple syntax.

Existing modern languages already provide an excellent developer experience: Go, Swift, Kotlin, Rust, and many more. Developers that can use one of these existing languages should. Unfortunately, the designs of these languages present significant barriers to adoption and migration from C++. These barriers range from changes in the idiomatic design of software to performance overhead.

Carbon is fundamentally a successor language approach, rather than an attempt to incrementally evolve C++. It is designed around interoperability with C++ as well as large-scale adoption and migration for existing C++ codebases and developers. A successor language for C++ requires:

  1. Performance matching C++, an essential property for our developers.
  2. Seamless, bidirectional interoperability with C++, such that a library anywhere in an existing C++ stack can adopt Carbon without porting the rest.
  3. A gentle learning curve with reasonable familiarity for C++ developers.
  4. Comparable expressivity and support for existing software's design and architecture.
  5. Scalable migration, with some level of source-to-source translation for idiomatic C++ code.

With this approach, we can build on top of C++'s existing ecosystem, and bring along existing investments, codebases, and developer populations. There are a few languages that have followed this model for other ecosystems, and Carbon aims to fill an analogous role for C++:

  1. JavaScript → TypeScript
  2. Java → Kotlin
  3. C++ → Carbon

Today, at the Cpp North convention in Toronto, as shared by Conor Hoekstra who was in attendance and documented the slides, Googler Chandler Carruth shared the vision for a new programming language called Carbon. To set the scene, Carruth showed how many of today’s most popular programming languages have successors that allow developers to be rapidly productive and also take advantage of modern language design.

Android developers well know that Kotlin serves as a successor to Java, just as iOS developers know Swift is the successor to Objective-C. TypeScript, from Microsoft, has thoroughly enhanced JavaScript, while remaining comfortable to use and able to be “transpiled” back to JavaScript. C++, which sees a significant amount of use within Google, is similarly a successor of sorts to the original C programming language.

While some may suggest that Rust, originally a Mozilla project that has since grown to have a significant public following, is a successor to C++, Carruth wonders if the analogy still follows. While Rust is undeniably a great language to start a new project in, it doesn’t have the same “bi-directional interoperability” of something like Java & Kotlin, making it difficult to steadily migrate.

If Rust works for you today, you should use it. But moving a C++ ecosystem to Rust is hard.

To that end, while Carbon has many of the same goals as Rust, such as helping developers to create “performance-critical software,” Carbon is also intended to be fully interoperable with existing C++ code. Additionally, the goal is to make migrating from C++ to Carbon as easy as possible, if desired.

As for why a C++ developer may want to consider introducing Carbon to their codebase, Carruth shared quite a few highlights of the language on stage. 

  1. Introducer keywords and a simple grammar
  2. Function input parameters are readonly values
  3. Pointers provide indirect access & mutation
  4. Use expressions to name types
  5. The package is the root namespace
  6. Import APIs through their package name
  7. Explicit object parameter declares a method
  8. Single inheritance; classes are final by default
  9. Powerful, definition-checked generics
  10. Types explicitly implement interfaces

Beyond the features of the language itself, the Carbon team drew attention to the development process that will shape Carbon’s future. The project’s code is hosted publicly on GitHub and is open for pull requests, while Carbon’s culture is outlined to be accessible and inclusive for employees of companies and private individuals, alike.

That said, one aspect of the Carbon programming language that’s not particularly well outlined is Google’s involvement. While today’s presentation was shared by a Googler, and the current project leads for Carbon consist primarily — but not entirely — of Googlers, there’s otherwise no mention of Carbon being a Google project.

This is actually intentional, as while Carbon got its start within Google, the team understands and has shared online that for it to have any future success, Carbon needs to be “an independent and community driven project,” not solely driven by Google’s own uses. In the same comment, Carruth further emphasizes that Carbon is currently just an experiment, albeit one that some companies have already shown early interest in.

carbon vs C++





If you’re interested in getting started with Carbon, you can download the source code and experiment with it on your own device. Or, you can get a feel for the Carbon programming language directly in your browser thanks to integration with the free Compiler Explorer web app.