Carbon: The C++ killer?

Mar 7, 2023by, Vaisali Sairam


The programming languages that people love to hate are disappearing quickly. Microsoft killed JavaScript with TypeScript, Apple killed Objective C with Swift, and JetBrains killed Java with Kotlin. Recently, Google announced a new experimental language called Carbon as a successor to C. Interrupting the existing C++ code base is a big deal because C++ is by far the most prolific language when it comes to building high-performance low-level systems. C++ has been around since 1983, and it has accumulated a lot of technical debt in the process. The creator of C++, Bjarne Stroustrup, once said, “Within C++, there is a much smaller and cleaner language struggling to get out.”

Creating a programming language that is analogous to C++ is no easy feat, but that’s exactly what Carbon aims to achieve. However, this is not uncharted territory for Google, as the company has successfully created programming languages such as Go and Dart, both of which are highly regarded in the industry. Despite lacking a logo or mascot at present, the creators of Carbon have a clear vision for the language’s purpose. They intend for it to be used for performance-critical applications, to facilitate software and language evolution, and to enable safe, simple, and easy-to-read code.

The language’s goals include implementing practical safety and testing procedures, as well as enabling rapid and scalable development. Additionally, Carbon has bi-directional interoperability with C++, which means that existing C++ libraries can be used seamlessly in Carbon and vice versa.

Getting started with the Carbon language involves the installation of:

Bazel: Google’s open-source build and test tool, which can support multiple languages and platforms.
LLVM: Low-Level-Virtual-Machine that the Carbon language uses to run.
Homebrew: Homebrew is a free, open-source package management system that streamlines software installation on macOS and Linux

Let’s take a look at the Hello World program in C++ and Carbon:

// C++ Program

#include <iostream>

int main() {
    std::cout << "Hello World!";
    return 0;


// Carbon Program

package ExplorerTest api;

fn Main() -> i32 {
  var s: auto = "Hello world!";

 return 0;

Carbon’s generic system is designed to be modern and robust, allowing users to pass types as parameters to classes and functions. One of the key focuses of Carbon is to improve memory safety practices, which is especially relevant since uninitialized variables are allowed in C++. While these variables can be useful for certain performance-related needs, they often lead to bugs, which can result in security vulnerabilities when exploited by hackers. To prioritize safety, Carbon has comprehensive documentation that outlines its safety strategy, aiming to balance performance and interoperability with C++. Users can also choose from different modes, such as Debug, Performance, and Hardened, to tailor their emphasis on memory safety as required.

It’s worth noting that Carbon doesn’t utilize mechanisms such as borrow checkings like Rust, reference countings like Swift, or garbage collection like Go. Additionally, while a sample Carbon interpreter is available, the Carbon compiler and toolchain are not yet operational. The Carbon Explorer is a tool for implementing the Carbon language, and it can be used to execute all Carbon programs. As Carbon is still experimental, some aspects may be subject to change.

Another recent language designed specifically to meet the needs of memory-safe performance applications is called Rust. So why not simply use Rust? The people who were already using Rust were encouraged to keep doing so. Developers that already have large C++ codebases that are challenging to convert to Rust should use Carbon. Carbon is built atop an already existing ecosystem, C++ in this case.

In conclusion, the world of programming languages is constantly evolving, and it’s not uncommon for new languages to replace or improve upon existing ones. Google’s new experimental language, Carbon, is the latest language to challenge the long-standing C++ language in the field of performance-critical applications. Carbon’s creators have a clear vision for its purpose, which includes improving memory safety practices and enabling safe, simple, and easy-to-read code. While Carbon is still experimental, it has the potential to become a game-changer in the world of programming languages, and it will be interesting to see how it evolves and how it is adopted by the industry.

Are any project ideas bugging your mind? We can be your best development partner! Connect with us here for more.

Disclaimer: The opinions expressed in this article are those of the author(s) and do not necessarily reflect the positions of Dexlock.

  • Share Facebook
  • Share Twitter
  • Share Linkedin