Early Impressions of Rust from a Go Programmer

F$&k the borrow checker, or “How I learned to stop worrying and love the compiler”.

Even though most of my day-to-day work is in Python, I still consider myself a Go programmer. I co-wrote the SSH server powering Bitbucket.org in Go and maintain a number of nontrivial projects, such as an easy to use SSH git server, an IRC library, and an IRC bot.

After reading Early Impressions of Go From a Rust Programmer, I started thinking about my experiences and how it’s been for me learning in the other direction and wanted to see what a similar article would look like.

Why Rust?

One of my favorite projects for learning a new language is writing an IRC bot. It handles network IO, text parsing, and potentially dispatching of some type. For me, this is usually the perfect level of complexity for playing around and learning, but complex enough to expand in the future. My current bot project has been alive for quite some time. It’s survived a few additional rewrites (mostly python with asyncio) and I’ve stuck with this one. Rust seemed like it might be a good fit and I had been looking for a lower level language that was easier to grok than C++ but more powerful than C.

At an initial glance, the features of Rust seemed to line up well with things I consider pain points in Go, so I figured I’d give it a shot.

Learnability

Rust is not a simple language. It has generics, traits, macros, async/await, and a borrow checker (among many other things). In particular that last one was hard to learn. I have a number of friends who have heard me rant endlessly while trying to figure out issues with ownership and the borrow checker, but at some point it just started making more sense. Unfortunately I don’t have better advice other than “it doesn’t make sense until it does”. It’s a useful property of the language which was initially hard to understand.

Generics, traits, and macros all had a similar learning curve for me. Lots and lots of initial pain followed by eventual understanding. For me, Rust has been worth the pain, but it definitely won’t be for everyone.

Things I Like

Rust has so many conveniences and niceties that come from a newer, more complex language. Many of these are direct improvements on things I consider pain points in go.

Things I’m Not Completely Sold On

In addition to things that were definitely positive, there were also some that were frustrating, but have a clear reason.

Things I Dislike

Takeaways

Both languages can learn quite a lot from each other. Rust’s enums, Result, and Option types would work amazingly in Go. Additionally, more powerful built-in async support would be incredible in Rust. At this point I think both languages have their place, but I think Rust fits better for lower level, resource constrained or performance critical projects, while Go is much easier for higher level projects.

Even though both languages could be thought of as replacements for C on a range of C to Python, Go is closer to the Python side (convenience while maintaining good performance) and Rust is closer to the C side (performance and safety at the expense of convenience). Both languages have value, and each comes with a separate set of trade-offs. In particular, I plan on eventually moving gitdir to Rust (as it has a higher expectation of security) but I’m still on the fence in regards to my IRC bot.

Discussion

Want to talk more about this? There are discussion threads at the following locations:

Thanks for reading!