Will Carbon replace C++?
March 1, 2023
|The Carbon project explores a possible future direction for C++ given the difficulties in improving it
|The Carbon language is still experimental. The roadmap indicates the period 2025-2026 for the release of version 0.2 which will mark the end of the experience. Version 1.0 is expected after 2026. The effort is driven by Google software engineers who have ceased involvement in C++ standardization, resigned from their official roles on the committee. Reason: A vote (in the standardization committee) on the issue of breaking ABI compatibility in favor of performance did not prove them right. It is from this misunderstanding that the Carbon project was born, announced as the successor to C++.
|The Carbon developers explain that while C++ is the dominant language for performance-critical software, its legacy and technical debt mean that its incremental improvement is a very daunting task.
|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? Because the language itself began as a fork from C. According to the Carbon team, C++ designers added rather than replaced features of the language over time, creating complex interactions between features. Preserving binary compatibility is another legacy issue. Also, the C++ board and evolution process is standardization rather than design oriented, slow, and sometimes fails to make decisions.
|The Carbon language will be familiar to C++ and C developers, but there are also many differences. Functions are declared with the fn keyword and variables with var. There are also strongly typed tuples. Type inference is supported by the auto keyword. Pointers are supported but not pointer arithmetic; the only pointer operations are addressing and dereferencing. Classes support single inheritance but not multiple inheritance.
|Memory safety is an important consideration but is not the primary goal. "The difference between Rust's approach and Carbon's is that Rust starts with security and Carbon starts with migration," reads the documentation. The approach is to simplify the language to create space for security features, then re-engineer the foundations to model and enforce security.
|After 31 years, a second language is making its debut for Linux kernel development: Rust. Rust support for Linux kernel development is seen as "an important step towards being able to write drivers in a safer language." Mozilla Research's Rust is the type of programming language that those who write code for basic input/output systems (BIOS), bootloaders, operating systems, etc. bear an interest. According to informed observers,it's the future of systems programming instead of languages like C or C++ .