Hopefully This Is Intelligible? - Tumblr Posts
a dinner date with rust
I’m a programmer and as a programmer I write code. There are a bunch of different programming “languages” that you can write code in, and one that I frequently find myself reaching for is called C. “Ok, cool, why do I care?” Well because C is monster that will eventually consume all of humanity. Created in the void from which all computing was born, it is The One Language that undergirds all the others. Rarely written but subtly permeating every crevice of our technology. It contains deep, dark secrets understood by only those steeped in the occult, the conduits to the souls of our computers, the systems programmers 🧙 (like me!)
oh and also pretty much every piece of software ever relies on it somehow ^.^ Don’t worry though everything is fine!
“Oh, that sounds Concerning!” you may say. Well, yes! Yes it is. And so Rust was born. The sales pitch for Rust goes something like this: “Rust! Because C is Bad and is Literally The Bane Of Your Existence.” Which... well, they make a compelling case! As a C programmer, I was skeptical of a language that claimed to have all the same features without any of the downsides, but eventually I decided to give it a go.
“Mmmmm tasty!” I say, biting into some bounds-checked arrays. I take a sip of the mutability rules and exclaim “Wow! This really is something incredible!”. For desert, I decide to order some of their world renowned ownership/borrowing system. It arrives, piping hot, and I begin to dig in. “Hmmm, this is nice... I think?” Worry begins to slip into my voice. I think to myself, “this does seem useful, but it feels like there’s some trade off being made here”. The waiter tells me how this was made with the worlds finest data race protection and my worry begins to grow.
A brief tangent on data races:
You know the little people who live inside the computer and make everything work? A data race is when 2+ little people are trying to work on the same project at once without talking to each other or making a plan. Things Will Go Wrong.
Data races are generally very bad and Rust does it’s very best to make sure that having one is literally impossible. The problem with that is that sometimes, you can have a data race, but it can actually be safe and fine and good! And by sharing the work, the program can finish it’s work much more quickly! However Rust is very quick to put it’s foot down and say “No! That’s too risky! I can’t allow you to put yourself in danger like that!” whereas C would say “Yeah, sure, go ahead, good luck ;-)”
So, this is where my dinner date with Rust started to go downhill. One of the things I write a lot of in C are “highly concurrent” which means that they have lots of little computer people working on them at once. It’s tricky, but it’s something I have a lot of expertise in. And when I tried to replicate those programs in Rust was fighting me at every turn.
It’s odd because while Rust is very picky about this stuff, and it even provides ways to tell it “Yes, I know what I’m doing, I promise you can trust me.” But these ways are just a little too clunky for my liking and proved to be enough of a pain to manage it really soured my whole meal. And I was so eager about it too!
I still would like to try Rust from time-to-time on smaller projects, but it’s really unfortunate that it’s just so unergonomic in many of the ways that matter most to me. And while it isn’t a great fit for my use-cases, I’d highly recommend it to anyone who wants to make their first foray into systems programming. For nearly everything aside from my specific use-case it seems to be leaps and bounds ahead of C, and C is really the only thing like it.
Rust is cool, tasty, and elegant to C’s old, rickety, and ugly, and it’s a huge boon for the systems programming ecosystem. But I get the sense that Rust isn’t exactly the C-killer it was made out to be and that C still has a place in the ecosystem (and our hearts 💖)