My experience learning Rust
Starting with Rust can feel a bit chaotic. It really pays off and feels great when you understand it
Overview
For two years, I have been learning Rust without following a strict learning path. My main reason for doing so was to try something that feels different. After coding in Javascript, Python, and Ruby for the last 8 years, it felt like I had been coding the same things over and over again.
Learning new frameworks and libraries under the same language can often feel repetitive and demotivating, but Rust was different. Its unique features kept me motivated and engaged in the learning process.
Where did I start
📖 The Rust Book
Everyone should really start here. It’s not the best documentation out there, I also recommend Rust in Action, but it’s a pretty good starting point to understand the core features within Rust.
🧠 Solving algorithms on exercism.io
I was able to find good katas on exercism.io to help me get accustomed to the Rust language. I found the exercises very engaging as they forced me to learn basic concepts such as Ownership, Borrowing, Types, basic error handling, parsing information, and more.
💡 You can find my repository of exercises here
🎄Advent of Code - 2021
Coding on Christmas because why not.
advent-of-code/2021 at master · aromeronavia/advent-of-code
📽️ Side projects!
Perhaps I got too ambitious on the projects I started, but I’m gonna list a few of them:
I was planning to develop a TUI that would help me understand how the
tui
crate worked, as I saw many interesting terminal applications and it really felt fascinating. I’m a big fan of Spotify-tui although it’s no longer being maintained 😢JIRA Tui was supposed to be an alternative to JIRA’s UI, so I didn’t have to navigate their portal and just mark my items as “In Progress” or done with a few keystrokes. I stopped too early as I didn’t feel motivated enough to continue, but here’s a small screenshot of how it looked
Here’s a more solid project I was working on! Spotuify was supposed to be a clone of spotify-tui, implementing every single feature in that project.
I initially started the application within a single thread, and then I realized that my codebase was becoming super complex and it felt wrong, as the UI was getting blocked as soon as I selected a playlist and it was fetching songs through the Spotify API.
I decided to deep-dive into the codebase for spotify-tui and try to understand what they were trying to do:
Multi-threading: The original spotify-tui architecture is multi-threaded, meaning that they spawn multiple threads for different purposes:
Playback Engine: Reproduce the songs
Fetching Data from Spotify
The actual TUI: ****handling keystrokes
Crate management: I had to understand a few things about how crates worked.
Crates are code libraries we can use in Rust to achieve different functionalities without implementing them from scratch.
Crates allow users to enable which features they want to use from a crate
If you have multiple packages inside your rust codebase, you can make inner packages point to the higher-hierarchy package dependencies by specifically pointing to those.
After spending a few weeks attempting to improve my codebase, I became stuck in an eternal loop of compiler issues, specifically related to async features (using tokio as a runtime). I made some progress and then paused my work. Hopefully, I will be able to return to this project soon. Although it was frustrating at times, it was also enjoyable. Additionally, as I am now working with Rust full-time in my current job, I am rapidly learning things that I did not understand previously.
💡 I’m actually just re-starting the development of this project 👀 got hyped enough writing about this one haha
Has it paid off?
I am now working full-time with Rust for two months, and I gotta say I’m really excited about what I have been able to do with the language. By far, this has been one of my best experiences when coding, because, as long as it compiles, it’s almost warranted my code will work 🤯
👌 The compiler messages are really detailed and they propose real solutions to your actual problem (although they sometimes can be overwhelming when you are just getting started with the language)
❤️ Error handling is one of the most beautiful things I’ve ever seen. I thought that Python’s error handling was the best, but now after trying Rust, I gotta tell it’s just better thanks to the Pattern Matching feature within Rust, and how explicit error handling is thanks to the Result<T> enum
A quick example of how pattern matching can work beautifully:
let result = perform_operation(); match result { Ok(data) => println!("It's so good to be alive"), Err(error) => match error { AuthenticationError => println!("Gotta authenticate first!"), WrongInput(input) => println!("Gotta fix your input {}, input), _ => println!("Gotta just fix something else!") } }
🚀 It just feels great, it’s really exciting to not see error messages like
undefined is not a function
Things I do not like about Rust (In and outside the language)
The majority of Rust job opportunities are related to web3, which is a market that I personally do not enjoy. I am grateful to be working on a non-web3 project at the moment 🙏.
The recent conflict within the Rust foundation was indeed something that raised some red flags within me whether Rust is a language to keep polishing my skills on. It definitely is, but it was in doubt for a moment.
Where next?
📓 I’m planning to keep learning the language and contribute more to the open-source community. I have recently subscribed to timClick’s patreon, and the content is just great, and the community he’s building feels very welcoming for all kind of Rust developers. I have been doing some good friends in the community so far!
🚀 I plan to continue developing in Rust for as long as possible. However, I understand that the market always needs Javascript, so I will also practice JS to avoid getting "Too Rusty". Good that my current gig requires me to mix between both.
🌐 I have done my first contribution to an open-source repository called
handlebars-rust
, and it excites me to keep contributing to the crates that I’m using.
Conclusions
I cannot tell you to learn Rust if you don’t see any value in learning it. I’m usually not the type of person that learns something because they need it, but because I wanted to have some fun. It’s a coincidence it’s paying off and I’m doing it as a job, but it might not be your case.
By any means I feel like an expert in Rust, I feel like I still have a lot to learn about the language.
If you are curious enough, give it a try and let me know what you think about it!
We are hiring!
At Neurelo we are trying to Simplify and Optimize how your applications work with databases. We are building a pretty exciting product around how developers interact with databases. If you are a Rust developer, we are definitely looking for some people in the space. To see a list of all our job posts, click here and apply!