Skip to Main Content

Learning Rust #5: Rustlings

Last December I finally started learning Rust and in January I built and published my first app with Rust: 235. Learning Rust is my monthly blog series that is defnitely not a tutorial but rather a place for me to keep track of my learning and write about things I've learned along the way.

Learning Rust series

This month I wanna talk about one particular project that is designed to help people learn Rust. It's called rustlings (lovely name btw) and it's a collection of exercises that walk you through basics of writing Rust.

The basic premise of rustlings is simple: there's a bunch of Rust files that don't compile. The design of the whole is beautiful: it will try to compile the exercises one by one in order and stops when the compiler fails. Now it's your job as the learner to fix the file so it compiles and save it. Once it compiles, you're introduced to the next exercise.

It's not exactly teaching you. There are hints you can activate if you're stuck but otherwise it's up to you to figure out how to fix the compiler's error messages and get the application to run. But it's a great companion for learning from documentation, tutorials or a book.

A screenshot of the rustlings app output with few successfull exercise prompts and a compiler error

I'm especially excited about the approach it takes. Not only does compiler-error driven development a great way to organize the tasks, it teaches you one of the key skills: debugging your app from errors.

As I've been teaching programming for years, the skill of reading those errors is often not talked about enough and causes many students to ignore them in the beginning. Instead of reading the error message and using its information to debug what's wrong, many beginners just go back to their code and try to figure it out. (I even wrote a humane guide to Python errors a while back to help beginners learn them.)

I learned about the project about 4 months into my learning journey and at that point, I felt comfortable and confident about the exercises. I think I would have benefited more had I started working on them earlier. Regardless, they provided a great way to make sure I understand the basics and provided an additional angle.

I've seen some other languages have projects that have failing tests that you need to fix (like Clojure Koans). This is the first one where I've seen the project being based on fixing errors and I'd hope to see more of them. I know from experience that creating good examples for these kind of exercises is super difficult so my hats off to the people who've built rustlings so people like myself can learn.