My Rust learning journey
When I decided to start learning Rust, I didn’t know exactly where to begin. Switching from dynamic languages, the trial-and-error method was ineffective. The error messages from the Rust compiler were not helpful unless you understood how Rust works. After six years of sporadic learning sessions, I still don’t understand Rust. But somehow, an undefined masochistic force inside me doesn’t let me give up and declare defeat.
The Book
So, what was my strategy to fight back and gradually build much-needed confidence when writing Rust? First, I decided not to take any shortcuts, like I did in my previous languages when I started learning them. I bought The Rust book and read it from A-Z without writing a single line of code. I remember it was like reading an excellent novel about how a programming language works. Still, the main benefit was that I also started learning how a computer system works at the CPU or memory level. When using high-level dynamic languages, these things are abstracted away because they favor other goals. And that’s fine. You know the mantra - pick the right tool for the job …
After I had completed the book, I took a break from Rust because everything seemed too complicated. Even printing out a simple “Hello world” didn’t go out without the compiler’s whining. Looking back, this was not Rust’s problem but just old human nature, where one gets used to something and is unwilling to accept changes required to embrace probably a different/better solution. This is the main problem when learning Rust as a beginner. You’re unable to understand why a particular way of doing things is better or needed compared to other (dynamic or garbage-collected) languages. This feeling has been the most significant challenge, especially in the first months.
First project
My second attempt to establish a long-lasting friendship with Rust was writing a simple CLI that would perform tedious and repetitive operations while deploying an app to AWS. I thought this could be a great and straightforward Rust project to check how well I put theory into practice (from the book). By reading other projects’ code, I got the required ideas for structuring such a project and compiling it as a release version. Even though the CLI worked, it left me with a bitter-sweet aftertaste. It was like when an AI code generator spits a bunch of code that you unconsciously glue with your own. It works, but you can’t explain why. Does it matter? Well, for me, it does. So, I took another step back and reread The Book. And this time, some of the things were much easier to understand. But still far from being able to code without many Rust compiler’s unforgiveness stops.
After self-observing where I have most of my problems, I simply can’t translate what I have learned from the book into the code. I must consider borrow checker, lifetimes, references, pointers, smart pointers, static and dynamic dispatch etc. to please the compiler. I asked myself, what am I doing? Am I a developer or a compiler’s toy? And at that moment, I decided to start practicing Rust fundamentals before I even started developing anything more significant. So, I found Rustlings to be a beautiful learning tool for beginners.
The breakthrough
I don’t remember how I came to one of the best books to learn Rust - “Zero To Production In Rust” - but this was the breaking point for me. The book wasn’t just about Rust; the author also shared numerous backend development best practices that I eagerly absorbed, chapter by chapter. And this combination showed me Rust from a different perspective. I could compare a particular solution written in Rust with my own version developed with - let’s say, Typescript (NodeJS). I started seeing how Rust handles errors compared to Javascript, how you can lean on Rust’s rich type system instead of writing your own custom logic, how you can achieve inheritance and polymorphism without losing your mind, and so on.
Once you find a gold mine, keep digging. And so I did. I started following on X (Twitter), the author of “Zero To Production In Rust” book ( Luca Palmieri ), hoping he’d publish more Rust learning gems. And I was lucky. It couldn’t have been a better time when he posted a link to a GitHub repository that included many Rust exercises. Why? I was about to start a project in Rust and was a bit rusty with my Rust (it’s been a while since I wrote anything meaningful in it). These exercises - 100 Exercises To Learn Rust - are a logical next step after you read The Book. You go from basic stuff to low-level system topics, like threads. The format of the exercises worked very well for me since I was “forced” to write the solutions that were then checked by an excellent CLI tool. Before each exercise, you also get a short and very concise explanation of a given topic, which builds the required context for the exercise.
Wanna be a Rustacean?
The “issue” with Rust lies in its many choices for writing Rust. Experienced Rust developers will say there is an idiomatic way of writing Rust, but it’s not so clearly defined by the language, like in Go. Therefore I often question myself if my Rust code actually looks and smells “rustish”? You’d say this is a secondary concern. And you’re probably right. But it’s more a personal trait that drives me to write Rust like Rustaceans. This led me to some additional learning resources that I found invaluable. One of them is Jon Gjengset. His YouTube channel is full of lengthy videos where he explains some of the difficulties Rust topics. One of them is asynchronous programming in Rust. I remember after watching his video where he described one of the primitives of the async rust - “Future.” I was able to connect the dots between several other elements that are usually present in asynchronous programming.
I felt so grateful for having Jon in the Rust community that I bought his book Rust For Rustaceans which covers more intermediate topics. Again, this was a logical next step in my Rust learning journey.
Conclusion
And why do I even learn Rust? If I had learned it due to market demand, then definitely not. Do I think there will be plenty of Rust jobs in the future? I don’t know. Maybe it’s a pure desire to learn a modern language that teaches you how a computing system works along the way. Rust is like a father who cares about you as a child and doesn’t offer any shortcuts because he knows nothing comes without dedicating time to build solid foundations for the time when stability is asked.