Red Rocket Software Logo

# Web3

Andrii Doroshko
Andrii DoroshkoNov 5, 2023

Carbon language

  • Why?
  • What to expect from carbon?
  • Field of application
  • The near and distant future
  • Conclusion

carbon-git.jpg

At the CPP North C++ conference in Toronto, Google presented a new development — not an IT product, but a programming language. Carbon was created to replace C++, which the company believes is developing too slowly.

Why?

C++ has many advantages, beginning with the fact that it is widely used by Google itself and ending with the point that it has taken the best from its parent, the C language. But the latter also has a disadvantage: C++ retains outdated C practices. 

These practices could have been eliminated, but the bureaucratic committee focused on standardization slowed things down. To add a single new feature, you have to wait years. 
Creating something new from scratch is much easier. But why create at all when there are excellent other languages for developers with their unique features? Well, Carbon was presented as an alternative to C++ — an alternative that will be easy to migrate to. 

The company also stresses that Carbon is not a development of C++ but a new language. At the same time, you can built Carbon products on top of the C++ ecosystem. It will be the same smooth transition or a combination as in the case of Java and Kotlin.

What to expect from carbon?

Carbon is a modern programming language with a code compiler written with LLVM (Low-Level Virtual Machine). It is also based on Clang — a C, C++, Objective-C, and Objective-C++ compiler.

Carbon provides the following features for developers: 

  • easy to learn (especially for developers who write in C++); 
  • complete set of tools and materials: compiler, libraries, documents, tools, package manager, etc.; 
  • C++-like code performance; 
  • bit-level access to addresses and data; 
  • portability with existing C++ code, including class and pattern inheritance; 
  • fast and scalable builds, compatible with existing C++ build systems; 
  • secure memory handling, including protection against vulnerabilities caused by accessing the memory after it has been freed, dereferencing null pointers and buffer overruns.
comparison-min.jpg
Code comparison with C++ and Carbon

The program "Hello, World!" written in Carbon: package Sample api; 
fn Main () -> i32
Print("Hello, World!"); 
return 0; 
}

Field of application

Nowadays C++ is mostly used for embedded applications, desktop applications and video games.

  1. As for embedded applications, they have a very long and complicated development cycle, similar to the traditional waterfall model. This industry still needs to migrate fully from C to C++, so there is still a long way to go before we migrate to Carbon. 
  2. Desktop applications are established products with millions of lines of code. It's unlikely that the companies will rewrite them to Carbon. They can write updates in the new language, but C++ developers will still be needed for support. 
  3. There are fewer maintenance issues in the video game industry. Development is also faster, and the game developer is more likely to innovate. So this is where Carbon can play an important role.

The near and distant future

Google itself says that Carbon is an experimental project. It means, among other things, that it still needs a working compiler. At Compiler Explorer, you can see what the new language is all about — at the level of basic syntax. 

The project's chief engineer plans to develop the language closely with the community. Carbon will be maintained on GitHub and will be discussed on Discord. The development team also wants to reduce contributions from Google or any other single company to less than 50% by the end of the year. And at the final stage of development, the project will be handed over to an independent software foundation. 

The developers will realize the foundation of Carbon by the end of 2022. However, the project's future is still vague, and the reaction of the IT community to the news is subdued — the C++ killers have tried to enter the market before. It's much more likely that Google will create a programming language to work on its internal projects.

But there is another way; if Carbon developers can fully achieve their goals, it will hit most spheres where it is crucial to have access to hardware, memory, and workflow optimization, i.e., everything at a low level. 

In this case, Carbon is expected to be used in game dev, programming for powerful embedded devices, networking, and the Internet of Things.

Conclusion

So far, Carbon's fate seems to be similar to Go — hype in the beginning and settling down in niche projects at the end. 

There are many reasons to believe that Carbon won't replace C++. At a minimum, it's a performance mismatch. At most, there's a lack of developer acceptance of the project that Google can't control. 

But what will really happen, we'll see in five years.