Episode 110

All the Rusty Things


February 25th, 2022

1 hr 5 mins 56 secs

Your Hosts

About this Episode

The Elixir Outlaws now have a Patreon. If you’re enjoying the show then please consider throwing a few bucks our way to help us pay for the costs for the show.

Elixir Outlaws, 19/02/2022

On today’s episode of the Elixir Outlaws, Chris Keathley and Sean Cribbs are going to talk about Embedded Systems, Microcontrollers, Rust, Raspberry Pi, Zig, etc. There is a compelling benefit of Rust, you can’t use this block of memory, and you can check that at compile time. There is a whole class of memory problems that Rust is stopping you from being able to interact with, but you kind of give it all up. If you dump the thing on a single-threaded, single-core M0 processor.

Episode Highlights
Zig is very appropriate for the embedded stuff, because if you are dealing with it, then you give up a lot of the benefits of Rust in an embedded context, says Chris.
There is a lot to work with Rust to, like write wrappers around unsafe type things to the point where you aren’t really getting a lot of its benefits.
There was a project in which Sean was working years ago that was leaning heavily on top of DPDK and which is the Data Plane Developer Kit. Basically, it lets you write network programs using kernel bypass. So, you basically get direct access to the network interface card, and it does some memory tricks and the network buffers into, huge pages that are user space rather than being, passed into kernel buffers and then hand it off with context switches into the userspace. So, you kind of gets the opportunity to do some packet-level programming there.
A whole class of problems could happen in a Zig Application that just can’t happen unless you use obviously giant caveat. On the other hand, Rust is going to keep you from making those mistakes.
Rust also has the notion of marking variables undefined, which was always a potential bug in C programs.
For those of you who don’t know, in old versions of C, you had to declare all your variables, you couldn’t declare them in scope, you couldn’t declare them, in your FOR loop, it had to be declared at a higher scope before you could use it in at least the version of C, which was like a pre ANSI.
Zig is an appropriate choice for the embedded work that Chris was doing, and he is starting to get into places where he really does want an arthouse like of some sort.
We are working on an API; its job is basically to produce these ginormous JSON documents and serve them to another app that produces the front end for our customers.
Sean could have switched back to Alexa or like Jason Library, but that would have made things worse, so there are still like times when you have to take that risky bet.
As a leader of an organization, you choose the culture you want, and then, based on that culture, you bring together people, and you tell them to make a decision, and then all you do is ratify that decision once they’ve come to a decision.
Sean recommends people to read the book “Kill It With Fire.” One of the things the author talks about is when there is a big problem, and they really want to solve it, the executives have to be into solving the problem. Sometimes they want to be to be involved, and they end up getting in the way. So, the strategy that she is picked in previous situations is they want to be involved, so they want to have a war room.
Chris has been in big company land where if you do anything without asking for permission in triplicate, you get your hands slapped.
There is a situation in mind where we are trying to figure out what the next major iteration of our platform is going to look like, and some of that means like questioning the assumptions that were made over the last three years building this product, and then you don’t like on the one hand we want to try things and see if they work like prototypes and whatnot and on the other hand, there is just a massive amount of functionality to figure out, says Chris
Chris is building new things then trying to get to the next level of the product.
Chris suggests that you can find everything you need if you search long and hard and kind of learn where it all is, it suffers mostly pedagogically like it doesn’t take you from nothing to an expert or even like semi knowledgeable. There is no path for that, and that is the thing that is really missing.
For Chris, coming back to an object-oriented language after being in functional land for so long, he gets really scared when he sees those sorts of things.
It is one of the few credo rules that Chris turns on from his laser stuff. He wants functions to have docs, and he wanted modules to have docs or at minimum have module block false, which is also again partially for he hides most of his internal modules.
You might change memory layout like your username is different than my username, and that changes the layout of how stuff gets into RAM, and that can result in a marked speed improvement.
Let’s use statistics and see our improvements are statistically relevant. Or if they are within the noise. If it is just noise, then try optimization Level 3, it is better than optimization level 2.
If we can find places in code, the problem with profilers as they show you where you spend all your time.

3 Key Points
Chris has written 50 to 100,000 lines of Rust at this point in various projects doing various things.
Sean and Chris discuss about the common problem in C language and how Zig is the much better version.
Rust is a better version of C++. C++ is a big old honking language at this point. Rust feels like that vein where it has a lot going on, setting aside the ownership stuff.

Tweetable Quotes
“All embedded microcontroller platform is a giant bag of global mutable state.”- Chris Keathley
“Rust compile-time memory safety stuff which is very novel and cool.” - Chris Keathley
“It is C that is keeping you from making some of the glaring C problems.”- Chris Keathley
“Zig appeals to me on an aesthetical level that Rust does not” - Chris Keathley
“Java is a safe bet because of adoption, not because of fitness to purpose.”- Sean

“If you are excited about it and getting invested in it, then that means a lot. It doesn’t eliminate risk, but it certainly helps to mitigate it when you make those big choices.” - Chris Keathley
“As a leader high up in an organization, you don’t make choices. You just bring together people who do make choices, and you ratify their choices.”- Chris Keathley
“Our team is responsible for some of the embedded work, which is largely built around nerves.” - Chris Keathley
“We have a deployment setup that’s really nice in that we can just use consistent hashing through a static cluster.” - Chris Keathley
“We made the loading spinner render faster, but it didn’t make loading any faster.” - Chris Keathley

Resources Mentioned:
Podcast Editing
Elixir Outlaws: Website

Support Elixir Outlaws