Announced a few weeks back at CppNorth developer conference in Toronto, Carbon is a new programming language being primarily developed by Google developers. The goal of Carbon is to provide a successor language to C++, by offering a modern more developer friendly language but also offering bi-directional support for C++, enabling you to call C++ code from Carbon and Carbon code from C++, making it an easier language to migrate to, while ideally keeping the positive traits of C++ such as high performance and low level control.
An obvious question with any new language is why? Why develop this language and not use an existing language such as Rust, D, Go or even C++.
Here is the reasoning from the GitHub homepage:
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:
- Performance matching C++, an essential property for our developers.
- Seamless, bidirectional interoperability with C++, such that a library anywhere in an existing C++ stack can adopt Carbon without porting the rest.
- A gentle learning curve with reasonable familiarity for C++ developers.
- Comparable expressivity and support for existing software’s design and architecture.
- 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++:
- JavaScript → TypeScript
- Java → Kotlin
- C++ → Carbon
Carbon is EXTREMELY early in development, not even a 0.1 release and many core features are not implemented. This is a language that is not even close to being ready for production use.
Key Links
Compiler Explorer Online Interpreter
You can learn more about the Carbon programming language in the video below.