Google invests $1 million to enhance interoperability between Rust and C++ programming languages

Google has promised $1 million to the Rust Foundation to enhance the compatibility between the C++ and Rust programming languages.

Although it’s called the “Interop Initiative,” its objective is mainly unidirectional, aiming to “organizations slowly migrate current C++ to Rust,” based on the announcement.

It’s no easy task because C++ is commonly used for large, performance-intensive programs such as modern games and operating systems.

Companies, whether for-profit or otherwise, that are deeply involved in C++ — in terms of talent, tooling, and generations of code — might not be so willing to switch to another (and somewhat challenging) language to learn, despite Rust’s supposed advantages of better security and improved dev productivity.

Even with the “growing popularity and adoption of Rust, it would be unrealistic to expect even the most technically advanced organization to easily pivot to Rust and away from the architecture of existing codebases,” acknowledged Rust Foundation Executive Director and CEO, Dr. Rebecca Rumbul, in a statement.

Nevertheless, actions are being taken. Microsoft recently formed a team to bring more Rust to its Office365 app substrate, MSPowerUser reported. The company has also pledged to use more Rust in the Windows kernel, citing ongoing security concerns with C++.

Similarly, Linux head honcho Linus Torvalds is open to the idea of using Rust for some of the core components of Linux, written predominately in C. Rust support is even being written into the GNU C Compiler (GCC).

Why Is Google so Interested in Rust?

For Google’s part, the company seems to be keenly interested in using Rust for memory safety. C++’s design indirectly encourages programmers to make errors in memory allocation, opening up the space for malicious actors to hack into these programs (The C++ tribe is working on this problem now).

“While Rust may not be suitable for all product applications, prioritizing seamless interoperability with C++ will accelerate wider community adoption, thereby aligning with the industry goals of improving memory safety,” wrote Lars Bergstrom, who is both the Google director for the Android platform tools and libraries as well as the chair of the Rust Foundation Board, in a blog post.

The use of Rust has already significantly benefited Google’s Android OS mobile operating system, by preventing hundreds of vulnerabilities that may have occurred with a less-memory secure language, the company has estimated.

Rust Code Should Be Able to Call C++ Functions Easily

To integrate Rust into predominantly C++ code bases, providing simple methods for functionality written in Rust to interact with existing C++ libraries is crucial by the way of wrapper libraries, direct tooling and build system support, and modifications to application binary interfaces (ABIs).

Much work has already been done. The software consultancy KDAB has created a set of Rust crates, called cxx-qt, that would help integrate Rust into C++ applications using CMake build system for C++ via the Qt cross-platform development framework.

Google itself has already invested in interoperability tools for both Android OS as well as for iChromium, including autocxx, bindgen, cbindgen, diplomat, and crubit,

To help things along further with Rust Google has also aggregating and publishing audits for Rust crates used in Google projects.

According to Google, many C++ libraries are already available to Rust through existing C++ bindings, such as bindgen.

Rust Programmers Are Interested in C++

According to JetBrains’ The State of Developer Ecosystem 2023, 12% of Rust developers use C++ alongside Rust.

In fact, 23% of Rust developers have already migrated applications from C++ to Rust, which accounts for 35% of all Rust developers that have migrated an app from another language instead of starting with a greenfield.

The Path Forward for the Interoperability Initiative

The initial plan for the initiative is to draft proposals for the scope of work, to be prepared by the Rust Project Leadership Council, with the inputs of Rust project leaders and “relevant” Rust Foundation member organizations, and its board.

No doubt, the initiative will want to hire a few engineers to build more integration points, as well as underwrite existing projects to keep going. The project may even look into the use of AI to speed things along.

TNS Analyst Lawrence Hecht contributed to this post.

Group Created with Sketch.

Leave a Reply

Your email address will not be published. Required fields are marked *