TNS
VOXPOP
Favorite Social Media Timesink
When you take a break from work, where are you going?
Instagram/Facebook
0%
Discord/Slack
0%
LinkedIn
0%
Video clips on TikTok/YouTube
0%
X, Bluesky, Mastodon et al...
0%
Web surfing
0%
I do not get distracted by petty amusements
0%
C++ / Linux / Rust / Security / Software Development

Google Spends $1 Million to Make Rust, C++ ‘Interoperable’

Eager to eliminate memory errors in C++-based Android apps, Google wants to make it easy for devs to write functionality in Rust instead.
Feb 5th, 2024 9:00am by
Featued image for: Google Spends $1 Million to Make Rust, C++ ‘Interoperable’
Feature image via Pixabay.

Google has pledged $1 million to the Rust Foundation to improve the interoperability between the C++ and Rust programming languages.

Though the project is called the “Interop Initiative,” the goal is more unidirectional in nature, to get “organizations slowly migrate current C++ to Rust,” according to the announcement.

No mean feat, given that C++ tends to be used for large, performance-intensive programs, such as modern games and operating systems.

Software-building collectives, for-profit or otherwise, that are heavily invested in C++ — in terms of talent, tooling, and generations of code — may not be so eager to shift to another (and somewhat challenging) language to learn, despite Rust’s putative benefits of better security and improved dev productivity.

Even given 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,” admitted Rust Foundation Executive Director and CEO, Dr. Rebecca Rumbul, in a statement.

Still, moves are being made. Microsoft recently spun up a team to bring more Rust to its Office365 app substrate, MSPowerUser reported. The company has also vowed to use more Rust in the Windows kernel, citing ongoing security concerns with C++.

Likewise, 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 inadvertently encourages programmers to make errors in memory allocation, opening 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 greatly benefited Google’s Android OS mobile operating system, by preventing hundreds of vulnerabilities that may have happened with a less-memory secure language, the company has estimated.

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

To get Rust into predominately C++ code bases, you need to provide easy ways for functionality written in Rust to interact with existing C++ libraries, 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 is, 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 autocxxbindgencbindgendiplomat, 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

First up for the initiative: A scope of work proposals, to be drafted by the Rust Project Leadership Council, with the input 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.
THE NEW STACK UPDATE A newsletter digest of the week’s most important stories & analyses.