We asked 5 people why they like Embedded Rust
Rust compiles to bare metal just like C and C++ do, but offers a modern language with a focus on performance, safety and usability.
We've gathered some quotes mixed with a little bit of background for you to enjoy.
Modularization & crates.io
The crate ecosystem makes it incredibly easy to modularize your codebase and quickly bring in complex functionality (e.g. full-featured ethernet stacks, USB-device stacks, device drivers, etc.) with a few lines of code.
Ryan Summers, Vertigo Designs
Pulling down dependencies is indeed very easy in Rust and a huge productivity boost. People online do express their worry that this can lead to situations à la NPM, but we haven't found this to be true so far. Embedded libraries are often low in dependencies anyways and with a little bit of self-control, you can avoid bad situations.
Ryan works at Vertigo Designs and does a lot of open-source work. One of the projects he contributes to is QUARTIQ Stabilizer, a flexible tool designed for quantum physics experiments and one of the most hardcore open-source Rust firmware projects.
Same tooling as for desktop apps
It's hard to choose any one thing that makes embedded Rust great because there are many. But if I had to make a choice, I would say it's that it brings all the great Rust tooling like Cargo and rust-analyzer to embedded platforms.
Maarten de Vries, De Vries Software
It is amazing how easy it is to set up your environment so that it supports embedded development. Just add the compiler target with one rustup command:
rustup target add thumbv7em-none-eabihf
And now you can compile code for the Cortex M4 & M7.
Want to flash it to your microcontroller? Just install a program that integrates with the Cargo tool:
cargo install cargo-flash # Compile the project and flash it to the chip cargo flash --chip nRF52840_xxAA
Maarten is a freelance software architect and developer with expert level knowledge of the Rust and C++ programming languages, Linux, computer networks and hardware integration and a strong affinity for the field of robotics. He works on Embedded Rust when contributing to RoboHouse, and previously at Fusion Engineering.
Easily switch between chip vendors
One great feature of Rust embedded is that the tooling works with multiple vendors, so moving from one chip vendor to another does not require learning a new tool and you can still use the same tools for creating your application. In the C world, this has traditionally been a feature of the RTOS, but with Rust it's just part of the language and tooling.
Most chip vendors don't support Rust yet, however, there are a lot of very good open-source libraries for many targets. Those libraries are often the only specific target code that your project contains.
To switch to a different chip vendor, you only need to update the code that is specific to the chip. All your tools stay the same. You can still use Cargo, your favorite IDE/editor, rustup, rust analyzer, etc.
Productivity and reliability
By leveraging Rust's type system and safety systems we can get new developers up and running in two weeks writing embedded code without the fear of getting crashes. Just follow the compiler errors and when it compiles, you know it works.
Emil Fresk, Widefind AB
We often hear that it can take a long time to get started with Rust and that's certainly true. However, if you already have an established codebase, making changes to it is likely easier than with a similar C codebase because when something breaks it can be caught by the compiler.
Rust is unique in allowing you to write fast, low-level programs, with modern tooling and ergonomics. There are only a handful of languages suitable for writing code where performance is a priority, or resources are constrained. Of these, Rust's language design, syntax, and official tooling make it the easiest to work with. (TLDR: The only options are C, C++, Rust, and maybe ADA or Zig. Rust has the best tooling and syntax of these!)
David O'Connor (firefrommoonlight)
David has a lot to say about embedded Rust! He must be the first person to have a TLDR inside a quote. But, this is his podium so here it is:
- Official, standardized, automatically-published documentation for the Rust language, and third-party libraries: Official docs page
- A standardized tool used to compile and flash programs: Cargo
- Official and included formatter and linter
- A standardized project structure and layout, including a project configuration file (cargo.toml) that contains publication metadata, and semvar dependencies
- High-level abstractions and data structures associated with modern languages
- Easy compiling, flashing, and debugging
Compared to equivalent code in C, ergonomic advantages include: not duplicating code between source and header files; not needing to prefix variables with the module name; explicit types for arrays (instead of relying on pointers); cleaner syntax in a number of areas
The major takeaway is that Rust has all the things you'd expect from a modern language and brings that to embedded as well.
One of the major things people like is tooling! Whenever we ask people, that's the first thing that comes up.
Hopefully, by now you have a sense of what people like about Rust. We will definitely be continuing to use it and create awesome applications.
Thank you to all the people who were willing to give a nice quote! It was really cool to meet you and learn more about how you are all using Embedded Rust in practice.