Project Carbon is an experimental successor to C++ backed by Google

Google Project Carbon is an experimental successor to C++.

Project Carbon is an experimental successor to C++ backed by Google

Given the difficulties in improving C++, Project Carbon, an experimental successor to it, investigates a possible future direction for it.

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 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 a modern generics system, modular code organization, and consistent, simple syntax.

In February 2020, the C++ standards committee held a pivotal vote on abandoning ABI compatibility in favour of performance. The initiative, which was primarily driven by Google employees, failed. As a result, many Googlers withdrew from C++ standardization, resigned from official committee roles, and clang development slowed significantly. The Carbon Project, announced as the successor to C++, arose from this schism. Given the difficulties in improving C++, the goal is to investigate a possible future direction for it. As a working basis, the Carbon project relies on C++ interoperability.

Google software engineer Chandler Caruth presented the Carbon language, described as an experimental successor to C++, at a recent C++ language event this week in Toronto, which piqued the C++ community's interest.

According to the Carbon developers, while C++ is the dominant language for performance-critical software, its legacy and technical debt make incremental improvement extremely difficult.

One solution is to migrate to other languages such as Rust, Kotlin, Swift, or Go, but doing so from C++ is difficult. Furthermore, in some cases, the latter have a performance overhead. Carbon is a new language that aims to match C++'s performance while maintaining seamless bidirectional interoperability and a gentle learning curve for C++ developers. The team also promises a certain level of C++ source-to-source translation. Although the comparison is not exact, the project has parallels with TypeScript for JavaScript developers and Kotlin for Java developers. Carbon is intended to be interoperable with C++ code and to make migration easier. The Carbon toolchain will be able to compile C++ code.

Why is it so difficult to enhance C++? Because the language originated as a branch of C. The C programming language is 50 years old, so it's not surprising that there's a lot of heritage. According to the Carbon team, over time, C++ designers added rather than removed language features, resulting in complicated relationships between features. Another historical concern is maintaining binary compatibility. Furthermore, the C++ board and evolution process is standardization-oriented rather than design-oriented, sluggish, and occasionally fails to make choices.

Carbon attempts to avoid these challenges by taking a fresh approach based on open source ideals. The documentation states, "We will even aim to fill a big void in the C++ ecosystem with an integrated package management." The current timeline is for the language to reach version 0.1 this year, 0.2 in 2023, and 1.0 in 2024 or 2025.

Carbon developers will be familiar with C++ and C, but there are numerous distinctions. Variables are defined with var and functions with fn. Strongly typed tuples exist as well. The auto keyword supports type inference. The only operations on pointers are addressing and dereferencing; pointer arithmetic is not supported. Single inheritance is supported by classes, but multiple inheritances is not.

With LLVM exceptions, the project is licensed under Apache 2. The team intends to establish an open source foundation and transfer all Carbon-related rights to it. "Our objective is to have the foundation constructed like other open sources projects like LLVM or Kubernetes," she says. The project does, however, now need participants to accept Google's CLA (contributor licensing agreement), which may be difficult for some. Google also contributes to Carbon's infrastructure.

The Source of this information is from Carbon Github