Android already supports Rust officially as a programming language for its development



Although they are still two of the most used and efficient languages, C and C ++ are also famous for their memory management problems. In fact, the team that handles Android development and maintenance within Google has expressed that memory security flaws in C and C ++ remain the most difficult source of Android code bugs to address.



This is one of the reasons why Google has not only been promoting the use of languages ​​like Java and Kotlin for a long time, but now, AOSP (Android Open Source Project) supports Rust as a language to develop the operating system itself.



Rust for the operating system, Kotlin for apps




Rust



When it comes to developing applications for Android, Google explains that languages ​​like Java and Kotlin are the best options. This is because those languages ​​are designed to be easy to use, portable, and secure.



Now, in the case of the operating system itself as such, Java and Kotlin are not an option. This is because the deeper layers of Android require programming languages ​​like C, C ++, and Rust, that is, languages ​​that provide access to system resources and low-level hardware, are light on resources, and have performance characteristics. more predictable.




In the case of C and C ++, the developer is responsible for managing the memory lifetime. Unfortunately, it's easy to make mistakes when doing this, especially in complex and multi-threaded code bases.



Rust provides memory security guarantees using a combination of compile-time checks to enforce the life / ownership of objects and run-time checks to ensure valid memory accesses. This security is achieved by providing performance equivalent to that of C and C ++.








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





This by no means means that Rust is going to replace C / C ++, and obviously adding support for a new language does not fix bugs that already exist in the other. As Android engineers explain: rewriting tens of millions of lines of code is simply not feasible.



However, the addition of Rust would reduce the number and density of future bugs, and would also improve the effectiveness of sandboxing on Android, which in turn also improves bug detection. The AOSP team has been working for 18 months to add support for Rust, and they say they have some projects that they will share in the coming months. Scaling this to more parts of the system is a multi-year project that is just getting started.



This is yet another boost to the growing popularity of Rust, a language that has been going from being relatively unknown, to being the most loved by many programmers, which has the potential to even replace C and C ++ within all of Microsoft, for precisely the same reasons that Android is supporting it, and that it has even generated a movement to bring it to Linux.