Professional Rustacean, 3 months in

Hi! 👋 I did end up landing that Rust job I was looking for, and I’ve been wrestling with the Rust programming language now for a good couple of months – not quite 3, if I’m to be honest, but who’s counting.

To be honest, I’m a little bit ambivalent. I think it’s a great language for a few reasons, but I will be honest in that I am not nearly as productive as I would be in other languages. For context, I’m using it mostly in web development, where my language and framework of choice is usually Ruby and Rails.

Yes, I am aware of the opinion on Hacker News that it’s a good language for low level use cases, but arguably not the right choice for web development. Then you have comments like this one that run counter to that narrative. I have to wonder why Rust seems to work at all levels for some, but not as much for me, but then I only have 2-3 months of experience with the language.

Anyway, these aren’t meant to be pros or cons, just notes.

It’s programmer catnip

I would guess that about 70-80% of programmers love rolling around in it, stuffing our faces in it, and playing with the language features. The reason is pretty simple – we’re generally technical people, and Rust has the wonderful characteristic of exposing us to all the technicalities underlying the systems we’re building, but with warning signs.

When I use Rust, I feel like I’m learning about the underlying systems and models. To take a cheap example, consider Rust’s string types. The fact that they are modeled in such a complex way reflects the complexity of string handling in computers. Learning how to use strings in Rust teaches you the difference between strings that are valid UTF-8, operating system strings, C-style strings, and the difference between borrowed and owned strings.

Does it suck? Yes. Is it educational? Also yes. Is it gratifying to eventually understand? Yes.

Learn to use Rust and you’ll learn about computing. And that’s a big draw to a lot of programmers, because there’s a big overlap between programmers and people who, well, like computers.

Type system gymnastics

In Ruby, where everything is an object, you often perform message passing gymnastics to glue everything together. If it quacks like a duck but you need it to walk like a human, well, you better get the duck quacking to the dog that barks at the human. You can inject anything anywhere, as long as it passes the right messages. It’s like infinitely interchangeable gears.

This doesn’t fly in Rust. Rust is not object oriented. Rust is more type oriented than object oriented. Just because two objects have functions with the same name doesn’t mean that they’re interchangeable. Things hinge more on whether they are the same type, or can be coaxed into that type, or implement the same trait. So instead of mashing objects together willy nilly, you need to figure out how to get from one type or implementation to another.

In Ruby, you can traverse the world via methods. In Rust, you must traverse the world via the type system. It’s a different trapeze, but you can still swing it.

Productivity tradeoff

I’m way less productive in Rust than I am in Ruby, at least for web development purposes. I am a lot more confident in the quality of the code, though. Oftentimes when I find myself attempting to write unit tests, I write one as a higher level integration test to check that the method I’m adding exists and behaves, but then any additional tests that I would have written in Ruby to handle edge cases are instead handled by the type system and simply refuse to compile.

That said, I am 2.5 months into this Rust journey and the type system gymnastics can definitely take a toll. But it’s such potent catnip that I find myself energized to come back to it again and again.

I think that confidence is invisible to business stakeholders, but I suspect that, despite the lower initial velocity, there’s much higher guarantee of quality and maintainability.

First, the Rust compiler probably won’t stop compiling your application code, at least for any code written in recent times, due to Rust’s stability guarantee. Probably. That’s just not true in Ruby. Breaking changes with no edition system mean that the chronological window for valid code shifts. Ancient code in other languages will bitrot faster than in Rust.

For instance, one of our Ruby code bases dates back to Christmas, Dec 2018 at the earliest, and no longer builds. Meanwhile, from the linked Reddit post above:

suffix 0.2.10 was published on April 15, 2015, one month before Rust 1.0 came out [and still compiles]

Examples of old (ca. 1.0.0+) Rust code that still compiles? : rust

That said, I’m still slower to write Rust than I am to write Ruby. Perhaps that’s due to a lack of familiarity with the language in practice – we’re measuring a decade or more of experience with Ruby with maybe a few months of professional experience with Rust.

Leave a comment