At Dwelo, we’ve written the code for our IoT gateways in Rust. It’s fast, it’s reliable, and it’s secure. But we didn’t start with Rust, and

We Rewrote Our IoT Platform in Rust and Got Away With It

submited by
Style Pass
2021-06-21 15:00:14

At Dwelo, we’ve written the code for our IoT gateways in Rust. It’s fast, it’s reliable, and it’s secure. But we didn’t start with Rust, and we didn’t write the code in a weekend. This series is the story of where we were a year ago, how we switched to Rust, and why you might want to think about doing the same. We will cover reasons to use Rust (or not!), threading, hardware communication, fearless concurrency, interacting with C libraries, writing an MQTT library from scratch, and the lessons we’ve learned the hard way.

A year ago, I joined an IoT startup with a mountain of legacy Python code running on a Raspberry Pi. Over the course of several years, this code had grown organically, as most codebases do. The original purpose of this code was to monitor an MQTT command channel, decode and execute commands on a Z-Wave network via a serial port, and report back success or failure via another command channel. In addition, the code was intended to report back information about the overall health of the system and the state of devices connected on the Z-Wave network. Somewhere along the way the software metastasized to control status LEDs and control a cellular modem over a separate serial port and communicate with the onboard release management software.

A senior software engineer on my hiring interviews desperately wanted to rewrite the whole thing, and I was leaving a C++ shop that was comfortably juddering along on the momentum of its prior successes. Spoilers: he wanted to switch the existing Python code over to Rust, and the prospect was so exciting I jumped ship from my old job and moved cities.

Leave a Comment