Last week, Google released Carbon, an Apache 2.0-licensed open-source experimental language intended to replace C++. Despite this ambition, professionals in the sector are skeptical.
The C++ language is a mainstay of enterprise development, but it has drawbacks and some developers feel it needs to be replaced. The reasons for this are many, including hard-to-learn and hard-to-read code, outdated security mechanisms, and a lack of fit for modern hardware architectures and environments, Listed Chandler Carruth, Principal Software Engineer at Google, during his keynote address. opening at the CppNorth conference on July 18, 2022. “Carbon will leverage the C++ ecosystem to try to address these issues, providing interoperability and easier code migration,” he adds.
Carbon is touted as being well suited for projects with a large amount of C++ code. However, switching to a new language will not be easy.
“The problem is, there’s a lot of C++ code,” says Andrew Cornwall, principal analyst at Forrester Research. “Changing the language would mean rewriting a lot of tricky C++ code to optimize, sometimes decades after the author retired. It wouldn’t be impossible, just expensive.”
Also, modernizing C++ might be a moot point. Developers who want to benefit from new features have already turned to other languages such as Rust, a programming language backed by Google, Microsoft and AWS, according to the analyst.
Eliminate C++ quirks and security issues
When C++ inherited from C, it bootstrapped the entire C++ ecosystem, which was critical to its success, Chandler Carruth recalls during his keynote. However, to these advantages – in particular the speed of the migration – were added coding particularities.
“For example, we put co_ in front of keywords because we’re terrified of breaking existing code,” says Chandler Carruth.
“C++’s many quirks make it a complex language. The syntax can be difficult to understand and write, which can lead to errors and bugs that are time-consuming and expensive to fix,” according to Morshed Alam, founder and publisher of Savvy Programmer, a programming learning site . “Furthermore, C++ is not well suited for enterprise application development.”
Andrew Cornwall agrees that C++ isn’t the best language for enterprise application development, but it has served well for building a series of basic frameworks.
” [C++] is powerful,” he says. “It lets you do a lot of things, including shoot yourself in the foot.”
Andrew CornwallForrester Analyst
Another problem with C++ relates to memory security, which poses a significant security risk, warns Dhaval Sarvaiya, co-founder of Intelivita, a development agency for games, websites and mobile applications. C++ data stored in memory has no access or overwrite controls, making it vulnerable to buffer overflow attacks, where malicious actors plant, control, or modify a process’s internal variables.
This major challenge is not a priority for the Carbon team, according to the team’s GitHub page. “Our initial priority is to immediately address important and easily solved problems in the field of security”, specify the engineers of Google.
The absence of real governance raises questions
According to Google’s Chandler Carruth, solving problems with C++ is hampered by the fact that it is a standard established by the International Organization for Standardization (ISO). And ISO’s strict rules make it necessary to ensure that nations and companies are represented in its definition. This would slow down language modernization work.
“This mode of representation does not make sense if the developer is tackling complex problems such as the technical debt of C++, which ranges from hard-to-understand arithmetic rules to the most annoying syntax, where the code does not what it seems to be doing,” he says.
For complicated problems like this, it’s more about having experts in place with a good decision-making process, advises Chandler Carruth. Because of this shift in priorities, almost all of Carbon’s development work will be done on GitHub with Google Docs for collaborative documentation editing, he said.
“The development process will come down to pull requests on GitHub – that’s it,” says Carruth.
However, this shift in focus from ISO processes doesn’t take away from the fact that Carbon will face the same issues as C++, such as interoperability and users wanting consistent builds, Forrester analyst points out .
“If Carbon is successful and establishes a meaningful code base, Carbon committers will be forced to establish a process for accepting or rejecting new language features,” he infers. “This process will become as bureaucratic as the C++ process is today. »
Carbon’s open-source development model poses an additional problem. “Most developers want languages to evolve slowly, and Carbon’s model of allowing anyone to contribute a new feature will hinder its adoption,” predicts Andrew Cornwall.
According to the project roadmap, Google expects no more than 50% from a single organization. However, governance of Carbon will remain in the hands of Google engineers until around 2024-2025, when project officials hope to turn it over to an open-source foundation.
Andrew CornwallAnalyst, Forrester
Clearly, Carbon maintainers may or may not accept pull requests on GitHub, while discussions will be conducted from two other communication channels.
No real alternative to C++ yet
In the past, languages such as D and Objective-C have made improvements over C++, but C++’s huge code base is hard to replace, Cornwall said. Rust is not an ideal substitute for C++, as it is not compatible with its source code and has no classes – a core idea of object-oriented programming. However, it supports modern features such as memory allocations that make it more secure than C++, he advises.
“The problem is compounded by the fact that the introduction of all new languages – even if they are not experimental – leads to the frustration of developers”, considers the analyst.
“Ask developers who started using Swift or Kotlin when these languages first appeared, and how they had to adapt as these languages evolved. They were often frustrated that they had to revisit the code they had already written and rewrite it to support the new version of the language,” he continues.
Since Carbon is still in the experimental stage, companies are unlikely to adopt it, said Leonid Ivankin, an Android developer at MTS group, a Russian telecom operator. “Carbon will undoubtedly thrive in startups that start a project from scratch,” he imagines.
For the moment, Carbon is not even ready for use, informs the GitHub page of the project, which evokes a hypothetical end of the experiments in 2023. But the very presence of Google at the head of the project is not necessarily reassuring. , according to the Android developer.
For the moment, the Carbon project has obtained 21,000 stars on GitHub, has been the subject of 830 forks and already has around sixty contributors.