Rust is a fairly recent programming language, it was first announced by Mozilla in 2010 but started by Graydon Hoare in 2006. It is behind the new, blazingly fast, Firefox Quantum web browser. It gained a lot of traction in the last few years for many very good reasons, especially for robotics.

Rust combines the advantages of low level languages such as C and C++ — mainly running really blazing fast with a really small footprint — but with a lot more guarantees that usually come from higher level languages. It prevents segmentation faults, guarantees thread safety. And where Rust particularly shines is that it enables all these safety and abstraction with no additional cost at runtime. Their motto is:

Rust: fast, reliable, productive — pick three

For these reasons, we believe Rust is the future of robotics because it enables developers to be fearless, to create and enforce standards, and to build and rely on a strong community. We explain why below, but first let us remind you what is hard in embedded software for robotics today.

Embedded programming is hard

Two main problems have proven difficult for embedded software:

It is extremely difficult to write safe code. C and C++ use of memory is unsafe and prone to human error. Many bugs are due to buffer overflow, data corruption, or read/write in unallocated memory. Not only these are very hard to detect and debug but many attacks and virus take advantage of it. The more complex your project become, the harder it is to maintain it. Said in another way: embedded programmers fear adding extra functionalities because it could break everything!

Concurrency is practically impossible to achieve in embedded software when going further than toy example or with massive overhead. Race conditions, deadlock, data corruption can cause bugs that are complex to debug. Especially in embedded system where the development environment is not as advanced as what you can have in the OS world. Debugging hardware interruption scares even the more courageous embedded developers.

You can find more details on why embedded software is hard here.

Beyond these technical aspects, there is also a lack of standardisation and directly reusable code, especially in robotics. Sure, there is a sample code somewhere on the internet for almost anything you want to do. But no two of them will work well together. As a result, developers today spend most of their time interfacing someone else code with their own, if not entirely recoding it. A lot of time wasted. A lot of security breaches introduced.

Rust can address all these problems, and more.