I have been using Rust as my primary go-to language for personal and hobby projects for a couple of years now, and thought I’d share some of my thoughts about this powerful and possibly underused language. With a pandemic still blowing over the planet, and perhaps a few days of holiday leave coming up, now is a really good time to try it out!
It’s fun after a while
Qualifying as the most loved language in the Stack Overflow developer survey over the last years, a lot of people in 2020 have at least heard about Rust. Still, at least among my developer colleagues, very few adopted it or even gave it a try. I think there are a couple of reasons for this, the primary ones being that the language is advertised as a systems programming language and that it’s a bit of an uphill climb before you can really enjoy it. I also find that most developers tend to have a “sphere of comfort and productivity” around one or two languages and are hesitant to move away from that.
Sure, Rust may be a systems programmming language, but I think a lot of people misinterpret this to only being able to write low level drivers and operating systems. Rust is actually a really nice general programming language that can be applied to a wide spectrum of devices, services and applications. So don’t let the systems programming tag fool you, Rust is really nice even for smaller hobby projects.
Also, Rust is not the easiest language to get started with. It has some basic concepts that are surprisingly hard to adapt to, at least coming from other programming languages. My best advice here is to leave (most of) your previous programming language routines at the door when initially approaching Rust. Trying to program in Rust in the same way you program for example C# doesn’t work very well. There are similarities of course, that you will likely benefit from having previous programming experience, but approaching Rust with an open mindset to pretty much everything really helps.
Getting started with rust is a lot like getting started with running. The first times you probably won’t enjoy it, or see any benefit of it, but if you stick around for a while you’ll hopefully begin to like it and eventually it becomes second nature.
Rust has a really aggressive compiler. Compared to most other programming languages, it can take a long time for new users to even get a program to compile and run. This is of course frustrating, and I think a lot of people give up on Rust here, but think about it for a while: the compiler is actually helping you identifying issues early on, instead of having more costly issues pop up later. However frustrating this might be, it is actually a good thing.
The benefit of this is that you can venture more fearlessly into traditionally complex areas like multi threading, knowing that the compiler won’t let through anything that can potentially break your program.
Use it everywhere
Rust has the benefit of being applicable pretty much everywhere. The thumb rule is everywhere you can use C, you can use Rust. And as you may know, C can be used on pretty much every CPU and micro controller available. So investing time in learning Rust means that you can use the same programming language for programming your micro controllers, smart watch, cars, airplanes, game consoles, etc, etc.
While the entire toolbox of Rust might not be available for all devices, and the tool chains to build and compile for some devices are not always the easiest or most ergonomic, the core Rust concepts apply everywhere - the ability to use modern, high level abstractions, package management, avoiding memory issues and race conditions, etc.
It’s easy to work with
The documentation for Rust is really good. The online Rust book should be the natural starting point for learning, and it covers the language really well. I also found the Rust Discord server to be really helpful for quick questions.
Rust has an impressive library of crates (packages). Browsing through Crates.io for getting new project ideas is always very inspiring. Chances are your next project already has some helpful packages ready and waiting for you, allowing you to cherry pick the fun things to do and leaving the boring/tedious/hard work to existing packages.
IDE and text editor support is also top of the line. You’ll find writing Rust code is really pleasant with code completion, formatting and documentation available for a wide range of editors from old school VIM to VS Code.
And of course, Rust’s major selling points: you don’t have to worry about common headaches like installing runtimes, memory management, race conditions, thread safety and still get your application running with blazing fast performance.
In reality, none of the above matters if you’re not enjoing it. Despite having all these nice performance gains from using Rust, the main reason I’m still sticking to it is because it’s fun. It doesn’t need to be more complicated than that. And I’m certain more people would enjoy Rust if you manage to hold on to your life raft during the first heavy storms that most likely will blow through your head when first trying it out.