Google adds support for Rust in Android AOSP development



Application developers may primarily opt for Java or Kotlin to build their applications, but the lower layers of the operating system itself need more robust and bug-proof alternatives, such as C or C ++. Google has now announced the support for Rust as a supported programming language in AOSP.



Hereinafter, the lower layers of Android will be able to combine C, C ++ and Rust, not very popular but very appreciated by those who use it. These languages ​​are designed with control and predictability in mind, being better options for accessing low-level resources and hardware.








Android made with Rust



For the past year and a half, Google has been progressively incorporating the Rust programming language in a select number of AOSP projects, such as the new Bluetooth stack.



Rust


The main advantage of Rust over C and C ++ is that it has mechanisms to improve memory security by reducing the need to use sandboxing, which consumes more resources and introduces latency in the process. Google highlights Two direct benefits of using Rust in Android development- Reduces the density of errors within your code and reduces the need for sandboxing.







Google, Microsoft and Mozilla are part of the new Rust Foundation to support the development of the programming language





With tens of millions of lines of code in AOSP, rewriting everything in Rust would be a daunting task as well as infeasible, so Google focus your efforts on using Rust in new developments and not in rewriting old code. In addition, according to Google research, it is precisely the relatively new projects that have the highest number of memory security bugs, and that will benefit the most from using Rust.



Memory


With a multitude of dependencies and toolchains that need to be maintained, tools and test infrastructure that need to be updated and developers that need training, Google considers that bringing Rust to a greater part of Android it's a multi-year project. For now, Rust will coexist with C and C ++ in Android development itself. For application developers there are no changes.



More information | Android Developers