WebProNews

Google Using Rust for Low-Level Android Development

Google is now using Rust for low-level development of the Android Open Source Project (AOSP).

Kotlin and Java are the primary languages used for creating Android applications, but C and C++ are still used for the core of the operating system (OS). Google is hoping to use the advantages Rust provides by allowing its use in the low-level OS.

Rust is very similar to C and C++, having many of the same keywords and commands. Like C, Rust also has no garbage collection, making it ideal for integration with C code. What Rust does have, however, is memory safety in the form of ownership.

Rust provides memory safety guarantees by using a combination of compile-time checks to enforce object lifetime/ownership and runtime checks to ensure that memory accesses are valid. This safety is achieved while providing equivalent performance to C and C++.

These features make Rust an ideal option for use in the underlying OS. Google has no plans to rewrite the entire Android code base, a task that would be prohibitive. Instead, the company plans on using Rust primarily for new code, where the majority of memory bugs exist.

Analysis of the age of memory safety bugs in Android (measured from when they were first introduced) demonstrates why our memory-safe language efforts are best focused on new development and not on rewriting mature C/C++ code. Most of our memory bugs occur in new or recently modified code, with about 50% being less than a year old.

Google’s announcement is good news for the Rust programming language, as well as for Android users.