Google Open Sources Alternative C++ Programming Language: Carbon

Produced | OSC Open Source Community (ID: oschina2013)

Google engineer Chandler Carruth announced at the CppNorth conference held in Toronto recently ①, officially open source Google’s internal programming language: Carbon, and said that Carbon is the successor of C++ (currently in the experimental stage).

Chandler cites some examples of the evolution of popular programming languages ​​today, such as: Java to Kotlin, Objective-C to Swift, JavaScript to TypeScript. C++, which is widely used within Google, is also regarded to some extent as the successor of the C language. He believes that these successors can help developers quickly become more productive and take advantage of modern language features.

Chandler also mentioned Rust, which was also initially touted as the successor to C++, but the relationship between the two is not as “two-way interoperable” as Java and Kotlin, making it difficult to migrate steadily. As for Carbon, it shares many of the same goals as Rust and supports full interoperability with existing C++ code, with the goal of making it as easy as possible for developers to migrate from C++ to Carbon.

Carbon Highlights:

  • Introducer keywords and simple syntax

  • Function input parameters are read-only values

  • Pointers provide indirection and variants

  • Use expressions to name types

  • Packages are in the root namespace

  • Import API by package name

  • Method declaration with explicit object parameters

  • Single inheritance, final class by default

  • Powerful and definition-checked generics

  • Types can explicitly implement interfaces

Comparison of C++ code and Carbon code:

At present, the code of Carbon language has been completely open source ②. Chandler said that while Carbon was born within Google, and its current project leaders are made up of mostly (not entirely) Google employees, it aims to be an “independent and community-driven open source project.”

If you’re interested in Carbon, you can download the source code③ and experiment on your own device, or experience the Carbon programming language directly in your browser through the Compiler Explorer④.

For the Carbon project, some developers have revealed some background information: In February 2020, the C++ Standards Committee voted on the proposal to “break ABI compatibility to ensure performance”. This work was mainly promoted by Google employees, but the final vote did not pass. As a result, many Google employees have stopped participating in C++ standardization efforts and resigned from their formal positions on committees, and clang development has slowed considerably. Based on these backgrounds, combined with Google’s goals for Carbon, the developer believes that Google really wants to make Carbon an alternative to C++.

The text and pictures in this article are from the OSC open source community

loading.gif

This article is reprinted from https://www.techug.com/post/google-s-open-source-alternative-to-c-plus-s-programming-language-carbon1d8178cd63b9a69a87bf/
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment