Menu
Google Android team embraces Rust for Android OS development

Google Android team embraces Rust for Android OS development

The Android Open Source Project has adopted the Rust programming language for use in new Android OS development, citing its memory safety advantages over C/C++

Credit: Dreamstime

Looking to prevent memory bugs, the Android Open Source Project now supports the Rust language for development of the Android mobile OS itself, taking on development tasks that have been the domain of C/C++.

In a Google blog post on April 6, members of the Android team stressed that correctness of code in Android was a top priority for security, stability, and quality. Memory safety bugs are a top contributor to stability issues, representing about 70 percent of high-severity security vulnerabilities in Android; safety bugs in C and C++ continue to be the most difficult to address.

Rust provides memory safety guarantees by leveraging compile-time checks to enforce object lifetime checks to ensure that memory accesses are valid, Android team members said. Further, Rust achieves this safety while providing performance equivalent to C and C++.

Rust joins a list of memory-safe languages for Android OS development that also includes Java and Kotlin. While the Android OS uses Java extensively to protect large portions of the platform from memory bugs, neither Java nor Kotlin are an option for lower layers of the OS. These layers require languages like C, C++, and Rust, which offer predictable performance in resource-constrained environments.

Further, with C and C++, developers must manage memory lifecycles themselves, which is prone to mistakes, especially when working with complex, multithreaded codebases. Rust manages memory use automatically.

C and C++ lack the same memory safety guarantees as Rust and require robust isolation. All Android processes are sandboxed and builders of the OS follow the “rule of two” guideline for code safety (namely, choose only two: code that handles untrustworthy inputs, code that uses unsafe implementation languages such as C and C++, or code that runs with no sandbox).

While this rule reduces the severity of security vulnerabilities, it has limitations. Sandboxing is expensive, consuming overhead and producing latency, while not eliminating vulnerabilities from code.

Memory-safe languages like Rust overcome these limitations, lowering the density of bugs in code, increasing the effectiveness of current sandboxing, reducing the need to sandbox, and enabling introduction of new features that are safer and lighter on resources.

The Android team’s memory-safety efforts will be focused on new development rather than rewriting mature C/C++ code. Most memory bugs occur in new or recently modified code. Team members also cautioned that adding a new language to the Android platform is a large undertaking, with toolchains and dependencies that need to be maintained, and test infrastructure and tooling needing to be updated. Also, developers have to be trained.

Rust support has been added to the Android Open Source Project during the past 18 months, with some early adopter projects to be revealed soon.


Follow Us

Join the newsletter!

Or

Sign up to gain exclusive access to email subscriptions, event invitations, competitions, giveaways, and much more.

Membership is free, and your security and privacy remain protected. View our privacy policy before signing up.

Error: Please check your email address.

Tags GoogleAndroidRust

Events

Why experience is the new battleground for partners

Join us for an exclusive webinar, in association with Hewlett Packard Enterprise and Technology Services Industry Association (TSIA) and learn about the latest industry insights and how technology services continue to evolve to deliver differentiated value, and how partners can be successful in 2021 and beyond.

Featured

Slideshows

Channel kicks 2021 into gear as After Hours returns to Auckland

Channel kicks 2021 into gear as After Hours returns to Auckland

After Hours made a welcome return to the channel social calendar with a bumper crowd of partners, distributors and vendors descending on The Pantry at Park Hyatt in Auckland to kick-start 2021.

Channel kicks 2021 into gear as After Hours returns to Auckland
The Kiwi channel gathers for the 2020 Reseller News Women in ICT Awards

The Kiwi channel gathers for the 2020 Reseller News Women in ICT Awards

Hundreds of leaders from the New Zealand IT industry gathered at the Hilton in Auckland on 17 November to celebrate the finest female talent in the Kiwi channel and recognise the winners of the Reseller News Women in ICT Awards (WIICTA) 2020.

The Kiwi channel gathers for the 2020 Reseller News Women in ICT Awards
Leading female front runners honoured at the 2020 Reseller News Women in ICT Awards

Leading female front runners honoured at the 2020 Reseller News Women in ICT Awards

The leading female front runners of the New Zealand ICT industry joined together for the annual Reseller News Women in ICT Awards event at the Hilton in Auckland, during which hundreds of guests celebrated 13 outstanding individuals who won awards, chosen from more than 50 finalists representing over 30 organisations.

Leading female front runners honoured at the 2020 Reseller News Women in ICT Awards
Show Comments