Google has introduced a new experimental language, Carbon, which is supposed to replace C++.
This is not the first programming language created in the bowels of Google. Over the years, Google has developed a number of programming languages, some of which have become more popular. In particular, Golang or Go was created as some kind of C analog with the aim of improving the development of servers and distributed systems and has since become quite common. Also, the programming language Dart has found its application in the development of client applications primarily using the Flutter framework. Nevertheless, the question may arise, why is another C ++ successor language needed, especially when today there are already a number of such languages, for example, Rust?
And the goal of the new Carbon language is to help developers create performance-critical software. However, unlike Rust, Carbon is also designed to be fully compatible with existing C++ code. Also, the goal is to make it as easy as possible to migrate from C++ to Carbon if desired. At the same time, it is emphasized that Carbon is still only an experimental language.
Some features of the Carbon language:
- Simple grammar
- Function input parameters are read-only
- Pointers provide indirect access and modification
- The package is the root namespace.
- API import via package name
- An explicit object parameter declares a method
- classes do not support multiple inheritances
- Generic support
- Explicit implementation by interface types
Comparison with C++. C++ code:
The same code on Carbon:
The Carbon language is being developed as open source, all of its code is available in the github repository: https://github.com/carbon-language/carbon-lang