Just last month, we saw the first baby steps toward the adoption of the memory-driven Rust programming language in the Linux kernel. Google has apparently been thinking in the same direction, and in a lengthy blog post Tuesday, the company announced that the Android Open Source Project now supports Rust for low-level OS components.
The Android team does a lot of work pushing Kotlin and Java into app developers, but those languages rely on Android Runtime (ART) to work. You can not write any lower level than ART in Java, as there is no runtime environment to run it on. In the past, Google typically used C or C ++, but none of these are memory-driven languages, and this opens up Android for memory leakage and buffer overflow.
Google describes the benefits of Rust over C / C ++ and states: “Rust provides memory security guarantees by using a combination of compilation time control to enforce the object̵
Google says rewriting “tens of thousands of lines” of existing C and C ++ Android code in Rust is “simply not feasible”, and rewriting old Android would have nothing to do as old code has gotten the most bugs knocked out of it by now. Since the Android source code is an open source project with billions of users, there are many eyeballs on it. Google says that “most of our memory errors occur in new or recently changed code, where about 50% are less than a year old.” Rust will be used for new components when needed, which can help reduce any new memory errors that Google could introduce.
Google closes the blog post, saying: “In the last 18 months, we’ve added Rust support to the Android Open Source project, and we have a couple of early adoption projects that we’ll share in the coming months. Get updated, we’ll post more updates on this blog. “