Can Carbon, the new programming language launched by Google replace C++ better than Rust? Carbon is for developers who already have significant C++ codebases


Frustrated by the slow evolution of C++, Google engineers have launched a new experimental open source programming language, called Carbon, which could succeed the venerable C++ which, for some, would be aging. It’s difficult for large projects to convert existing C++ codebases to Rust, say Google engineers.

Chandler Carruth, senior software engineer at Google, presented Carbon this week at the C++ conference CPP North Toronto. According to some observers, the new version of Carbon should be interoperable with popular C++ code, but for users looking to step up a gear, the migration should be fairly easy. For those who aren’t sure you want to switch completely, Carruth went into more detail about some of the reasons why Carbon should be considered a powerful successor to the C++ language, including simpler grammar and smoother API imports.

Google engineers are already building tools to translate C++ into this new language. Although Carbon started as an internal Google project, the development team wants to reduce contributions from Google, or any other company, to less than 50% by the end of the year. The designers want to release a basic version 0.1 by the end of the year. Carbon will be built on a foundation of modern programming principles, including a generic system, which would remove the need to check and recheck code for each instantiation.

Memory safety is another essential feature that C++ lacks. Memory access bugs are a leading cause of security exploits. Carbon designers will look for ways to better track uninitialized states, design APIs and idioms that support dynamic boundary checks, and create a comprehensive default debug build mode. The designers plan to build a safe subset of Carbon. According to the documentation, the language will support:

  • rapid and scalable development;
  • performance-critical software;
  • the evolution of software and language;
  • code that is easy to read, understand and write;
  • convenient security and testing mechanisms;
  • modern OS platforms, hardware architectures and environments;
  • interoperability with and migration from existing C++ code.

The development team will also focus on creating an integrated package manager, which is sorely lacking in C++.

Here is a C++ code translated to Carbon. First, the C++ code:

Here is the same function written in carbon:

Carbon will be a better replacement for C++ than Rust?

Rust is a multi-paradigm compiled programming language, designed by Graydon Hore then employed at Mozilla Research, with input from JavaScript creator Brendan Eich. Used by several large companies and by many developers around the world, Rust has become the base language for some of the fundamental functionality of the Firefox browser and its Gecko engine, as well as for Mozilla’s Servo engine.

Microsoft

Microsoft is a founding member of the Rust Foundation and says it wants to work with the community to continue improving the language. The company promises to provide tools, a language library, and learning resources.

According to Nell Shamrell Harrington, software engineer at Microsoft and board director of the Rust Foundation, open source software and languages ​​are of critical importance to his company and to the tech industry as a whole.

In addition, Microsoft recently formed a Rust team to help with engineering efforts for the language ecosystem. The software development company plans to work with the Rust community on the compiler, core tools, documentation, and more.

Google

In an announcement made on its blog on February 8, Google said it was delighted to have joined the Rust Foundation and was ready to work on issues such as interoperability with C++. Building on Google’s long-standing investment in C/C++ and compilers and toolchains, we are thrilled to announce our membership in the Rust Foundation, Google announced on its blog. We look forward to further participation in the Rust community, especially working on important issues as a whole, including interoperability with C++, coordinating security reviews, reducing update costs, and continuing to increase our investments. in existing Rust projects, the company added.

According to Google, memory security flaws are a frequent threat to device security, especially for apps and operating systems. For example, on the Android mobile operating system, Google says it found that more than half of security vulnerabilities addressed in 2019 resulted from memory security bugs. This, despite the considerable efforts made by the company and other contributors to the Android Open Source Project, to invest in or invent various technologies, including the AddressSanitizer, improved memory allocators, and numerous fuzzers and other coded.

Amazon Web Service (AWS)

Amazon, for its part, has clearly recognized that it is the main beneficiary of the Rust language and the work of its community. The company is happy to be able to participate in the future success of Rust. According to Shane Miller, head of the Rust team at AWS and also a university professor, the reason engineers choose Rust to build services is because it allows them to deliver customer experiences that meet their quality and security much faster and at a lower cost.

AWS uses Rust to provide services such as Amazon Simple Storage Service (Amazon S3), Amazon Elastic Compute Cloud (Amazon EC2), Amazon CloudFront, and more. Recently, the company released Bottlerocket, a Linux-based operating system written in Rust. The Amazon EC2 team uses the Rust language to develop new components of the AWS Nitro system, including sensitive applications, such as Nitro enclaves. For Shane Mille, as a founding member of the Rust Foundation, the company will dedicate itself to one of the goals of the Rust Foundation which is to empower Rust maintainers to happily do their jobs.

Why not use Rust?

Long the language of choice for building performance-critical applications, C++ suffers from a number of issues that plague modern developers, Carruth explained. It has racked up decades of technical debt, bringing with it many outdated practices that were part of the language’s predecessor, C. package management ecosystem, explains Carruth.

Language evolution is also hampered by a bureaucratic committee process, geared towards standardization rather than design. This can make it difficult to add new functionality. C++ has a largely sequestered development process, in which a select committee makes the important decisions, in a cascading process that can take years.

The comparison between Rust and C++ remains a hot topic, as these programming languages ​​compete in areas like systems and embedded development. From a technical point of view, the two languages ​​share many similarities in their syntax. However, Rust and C++ have significant differences.

C++ is a compiled programming language that allows programming under multiple paradigms, including procedural programming, object-oriented programming, and generic programming. Its good performance and its compatibility with C make it one of the most widely used programming languages ​​in applications where performance is critical.

Moreover, it is a general-purpose language, which means that it can be used in almost all cases. However, due to its complex syntactic rules and overall difficult usage, it is mostly dominant in applications that require high speed, concurrency, and closer scrutiny of hardware operation.

However, memory safety is another essential feature that C++ lacks. Memory access bugs are a leading cause of security exploits. Carbon designers will look for ways to better track uninitialized states, design APIs and idioms that support dynamic boundary checks, and create a comprehensive default debug build mode.

For some analysts, C++ has a stronger foundation in terms of community and general information about its principles. Also, compared to C++, Rust is a relative newcomer to the programming world, and many developers are hesitant to get into it.

The end of C++?

Just as Microsoft created Typescript to update JavaScript and Kotlin was created to address the weaknesses of Java, Carbon could serve as a successor language to C++, a language that offers developers an easy jumping off point to a newer language that supports take into account modern development concepts such as memory security and generics.

The committee structure is designed to ensure representation from nations and companies, rather than building an inclusive and welcoming team and community of experts and people actively contributing to the language,” writes Carruth. Access to the committee and the standard is restricted and costly, attendance is required to have a voice, and decisions are made by votes of those present.

Carruth wants to build Carbon through a more open, community-driven environment. The project will be maintained on GitHub, and discussed on Discord. Although Carbon started as an internal Google project, the development team wants to reduce contributions from Google, or any other company, to less than 50% by the end of the year. She finally wants to entrust the project to an independent software foundation, where its development will be led by volunteers.

In his CPP North presentation, Carruth advised those who use Rust to keep using it. Carbon is for developers who already have large C++ codebases that are difficult to convert to Rust. Carbon is specifically what Carruth calls a successor language, which is built on top of an already existing ecosystem, C++ in this case.

It’s designed around interoperability with C++ as well as wide-scale adoption and migration for existing C++ codebases and developers, the designers explain. This means that the language must be as powerful as C++, that it must offer transparent and bidirectional interoperability with C++.

Source: Google

And you?

What is your opinion on the subject?

Is Google trying to kill C++?

Why Carbon over Rust to improve security and memory issues in C++?

Do you think the end of C++ is possible?

See as well :

Microsoft, Google, AWS, Huawei, and Mozilla are teaming up to create the Rust Foundation, a nonprofit to run the programming language

The Carbon project, an experimental successor to C++, explores a possible future direction for C++ given the difficulties of improving it and relies on interoperability as a basis for work.

C3: a system programming language based on C, allows secure access to arrays, high-level containers and manipulation of character strings

Leave a Comment