Will Carbon Language Succeed Where Rust and Haskell Failed? A New C++ Successor
On July 19th, 2022, Chandler Carruth from Google announced Carbon - a new programming language that is said to possibly replace C++ in the nearest future and become its true successor. Starting as Google’s internal project, Carbon is now quickly gaining traction and its creators hope to reduce the contributions from Google to less than 50% by the end of 2022, thus making Carbon a true open-source tool. So what are Carbon’s true stakes in the programming Game of Thrones, and can it really offer something that C++ can’t and won’t be able to?
A quick overview of C++ and what developers hate about it
C++ is a general-purpose language that first made its appearance in 1985. Since then, C++ has evolved significantly and now an overwhelming number of desktop apps, operating system kernels, compilers, gaming engines, databases, and virtual machines run on C++.
One of the biggest advantages of C++ is its speed: for example, the language is very undemanding for memory or battery charge. As well, C++ provides lots of control over hardware and many developers seem to really enjoy working with C++ templates - though some engineers compare work with them to the Stockholm Syndrome. But in general, C++ is pretty versatile, has good functionality, and allows writing working and fast code. What can go wrong?
As for the drawbacks, one of the biggest drawbacks of C++ is its low security. For instance, the language allows array overruns or can address freed memory by mistake. As well, some developers heavily criticize C++ syntax and one of the issues with C++, addressed by Chandler Carruth, was that work on a C++ parser is a big headache (and Carbon aims to make it better).
Now that we have a better understanding of C++ and what’s criticized the most about it, let’s move on to the languages that attempted to outshine C++ and take its place.
Haskell and the story of loud rise, loud fall
While most people remember Haskell and Rust being the main languages that attempted to replace C++, there were actually many more attempts, such as Vala, Cyclone, Limbo, and BitC. However, it was probably Haskell that got the most attention and for some time, this language really ruled in the software development landscape. So what happened to it despite its popularity and efficiency?
The rise of Haskell popularity happened during late 2000s-2010s. Haskell is a general-purpose, purely functional language that pioneered quite a number of features like type classes. An impressive thing about Haskell was that at a time, this language was at the forefront of functional programming, leading the way to Scala and Golang. Even C++ has learned a thing or two from Haskell. There were many big projects realized in Haskell, there were many big promises made and yet, this language just kind of disappeared. So what happened to it?
The thing is, Haskell was and remains awesome. It’s powerful and it displays insane productivity - developers could design and ship an application in Haskell 5X faster than in C++ or Scala. However, Haskell is often called “a language for geniuses and academics and the Haskell community (in the opinion of many developers) was too arrogant and condescending, thus simply scaring away potential Haskell engineers. In addition, the language was too parochial, meaning it was not able to address the general needs of an enterprise. Haskell displayed stellar performance - but within very particular circumstances. Compared to C++ with its massive community and insane diversity of use cases, Haskell was quite doomed in terms of replacing C++.
Next on our list of unsuccessful C++ assassin is Rust. Even though this programming language is still widely used and is actually quite popular, it also was not able to replace C++ and become its successor.
Rust is a general-purpose, multi-paradigm language that was first released in 2010. The syntax of Rust is similar to the one of C++ and what set Rust apart from C++ was its increased safety. Safety is one of the primary areas of focus of Rust, and it takes excellent care of memory safety and safe concurrency - something that C++ is known for having issues with.
However, if we dig deeper, the safety of Rust is not such an outstanding feature. True, the language is safer than C++ but mostly due to the built-in static code analyzer that catches all bugs typical for C++. However, there is a variety of both dynamic and static analyzers for C++ as well, with Google sanitizer being an excellent example. In addition, C++ remains faster than Rust which is also quite a drawback.
Finally, C++ simply has a bigger community and people are not interested in rewriting their existing massive applications and programs in Rust just because it’s considered a better alternative by some people. In this way, Rust remains both alive and dead. While its popularity keeps rising, according to various surveys (such as a Stack Overflow one), in real life, developers seem to prefer C++ and there are not as many Rust enthusiasts out there as the numbers in reports show.
Carbon: a Google’s attempt to make things better with C++
Now, it’s time to talk about Carbon. With lots of hope anchored on it by the developers’ community, this programming language should really offer something unique that Rust and Haskell were lacking.
The biggest trump card of Carbon that might help it replace C++ is its interoperability with C++. While many developers claim that learning Rust is like learning a totally different programming language, the transition from C++ to Carbon is promised to be smooth and easy. As well, Carbon creators claim that conversion of C++ codebases into Carbon should not be a problem either. This is actually a really big advantage since companies did not want to spend massive amounts of money, time, and resources on switching their existing codebases to a totally new language. With Carbon, this issue will no longer be relevant (at least according to Google).
So what is Carbon and what do we know so far about it? It is an open-source and general-purpose programming language which for now remains experimental. As Carbon developers admitted, the language is not ready for the use yet, and it is intended mainly for easy migration from C++ (at least for now). As well, Google really hopes that most contributions to Carbon development will be community-based, and this is one more goal for Carbon to achieve.
What sets Carbon apart from its competitors is an impressive list of promised features that are aimed at eliminating current C++ issues and enhancing performance. These features include:
- Memory safety due to better tracking of uninitialized states and design APIs and due to a comprehensive default debug built mode;
- Direct manipulation of hardware that Carbon runs on;
- Gentle learning curve so C++ developers can switch to Carbon easily;
- Read-only values are function input parameters;
- A built-in package manager;
- An option to import APIs by their package name.
And the list goes on. However, it’s an interesting thing that the D programming language already realizes many things that Carbon only plans to do so it’s something Carbon developers really have to consider.
To sum up, the developers behind Carbon really aim to surpass C++ in terms of functionality and performance while retaining its speed. Will they be able to do it? Only time can tell. Meanwhile, C++ developers can continue working on their C++ codebases because the language does not seem to go anywhere in the near future.
Irina is a professional copywriter with over 7 years of experience in this domain. She loves creating compelling and informative copy that provides readers with all the needed information. Irina is also a frequent contributor to different blogs and websites across different domains.View all articles by this author.
Makes sense for Google to take this step. Their chrome and chromium codebase is huge. As for me, my biggest gripe with carbon is syntax...