After my recent detour into mobile app development I finally got back on track with my plan to learn more Rust. Or, as it has been a while since I really wrote any proper Rust code, first refresh my memory a bit and accustom myself with the language again to feel more at home with it.

As Rust is no longer just a promising newcomer but has been around for a while already and seen some proper use, one can easily find tips online about how to learn the language or deepen one's knowledge in it. After reading through some of those I decided to try two well-received free sets of exercises that were recommended by many and sounded good for my use case: Rustlings and the Rust track on Exercism.

A quick comparison of Rustlings and Exercism

I started with Rustlings, and after finishing it moved to Exercism. I've only completed about 10% of the latter but as I've already spent several days in it also, I decided to write down some thoughts about both.

The nice similarities

Both exercise sets seem to be well-thought-out and the instructions for starting out are really clear and user-friendly. They have a similar approach to checking one's exercises: each has a set of tests for every exercise, and once those pass, the exercise is considered complete.

Both Rustlings and Exercism also have a command-line client so one can easily work on the exercises locally and then advance using the provided client. Exercism has an online editor for doing the exercises in the browser but I haven't tried that as I wanted to work on them in my usual working environment, i.e. local IDE. Rustlings also has an older online version available but I didn't try that either.

Rustlings

In Rustlings, there are plenty of exercises, grouped under several topics. They have a recommended order, where all exercises for a particular topic follow each other linearly. The whole set can be fetched in one go by installing Rustlings locally following the given instructions.

The runnable client has a watch mode that keeps running the tests of the current exercise. It actually keeps running through the whole set of exercises, advancing from one to the next once all the tests for the current exercise pass and the user removes a certain "flag" comment from the source code. By leaving the comment in place the user can continue working on an exercise even after the tests pass if they want to improve their code or try a different approach.

Alternatively the same functionality can be run without watching for code changes. It's also possible to run the checks for any particular exercise if one doesn't want to follow the recommended order for the exercises but e.g. try some particular topic instead.

One can also get a hint for the current exercise with the client. This also works in the watch mode by typing the word "hint" in the terminal. This actually came in handy on a couple of occasions.

All in all, I think this works really nicely and at least for me everything worked perfectly by following the given instructions. The only downside was that once I got near the end of the set, if I took a break and stopped the client, it took a while to reach the first incomplete exercise when started again as it first checked all the ones I had already finished, advancing in the recommended order starting from the first exercise. But I didn't do this often, so it definitely wasn't a big problem in the end.

The only bigger gripe I had with Rustlings was that sometimes I found it a bit unclear what I was expected to do, and the hints didn't really help much in these cases. But this only happened in perhaps 2-3 exercises and there were over 90 of them, so my general experience was very positive.

I'd also like to thank Rustlings specifically for introducing me to Clippy. It gave me some good suggestions on my code during the exercises, and I've since kept on using it and find it very useful especially for a Rust beginner. (It's possible I had actually read the appendix of The Book that mentions useful tools, Clippy included, or that a former colleague of mine had mentioned it to me earlier. But if that's the case, I had already forgotten about it...)

Exercism

Whereas Rustlings is a Rust-specific open-source project for learners, Exercism is a complete platform for learning programming languages. This is the first time I've used it and I've only tried the Rust track now, so my comments might not apply to its other tracks. Also, as mentioned earlier, I've only finished 10 of the 103 Rust exercises it has available, so it's possible my opinion of the exercises or the platform will still change.

Anyway, from the very beginning Exercism has felt like a really easy and user-friendly platform for starting learning a new programming language. But even if using the platform itself is easy, some of the exercises definitely haven't been. A bit more on that later.

Exercism has loads of exercises divided into topics or concepts. Some of these are available from the beginning, and others can be unlocked by completing those. Some exercises belong to more than one topic, and the syllabus is more like a tree or a map than a straight line, which gives freedom in advancing and jumping between topics. One could do this in Rustlings also by manually running particular exercises but the visualization on the Exercism site makes this easier.

Unlike Rustlings, one fetches each Exercism exercise separately to one's machine by using the provided client. Then one can work on the code locally (by using e.g. cargo watch) and once all the tests pass and one is happy with the code, submit it to the Exercism server using the client again.

Even though Rustlings provided the watcher as part of the service, I don't mind using Cargo manually for it. But sometimes I felt a bit stuck, and I kind of missed the hint functionality of Rustlings when doing the Exercism exercises.

However, once one submits their solution to an exercise it really becomes clear how the two are totally different beasts. As a complete learning platform, Exercism has solutions from other users available on the platform itself (once one has completed the exercise in question themselves) and also offers free mentoring by other users. I haven't asked for mentoring yet but have found the example solutions from other users very valuable.

The reason why those are so valuable is that some of the harder exercises can get quite big, especially if one doesn't know all the bells and whistles Rust has — which is quite likely when the user is new to the language. So seeing how some more experienced Rust programmers have solved the same task in much less code can be really beneficial. However, some high-ranked solutions seem like code golf to me, and perhaps not very readable or clear. That's probably because I'm not fluent with the language yet, and I do find them educating as they introduce me to new tools in the language. But some are downright cryptic which isn't ideal.

All in all, I've enjoyed the Exercism exercises quite a lot, although I've grown a bit tired with some of the hard ones after banging my head against the same wall for a long time. Which brings me nicely to my next topic.

General thoughts about learning Rust

I would love to love Rust. I guess the same applied to ANSI C when I wanted to learn it and completed a course on it at the university. I really like taking a look "behind the scenes", so to speak, and these low-level languages make me feel I'm doing just that. But on the other hand, I fear I enjoy higher-level languages a bit too much in comparison.

While doing all these Rust exercises, as well as writing my own very small pet projects, I think I keep banging my head constantly to the same walls. I don't think it's surprising that in this case those are related to Rust's ownership and lifetime rules.

It's all for your own good

I realize how all that nagging the Rust compiler gives me is exactly what makes the language so good. The philosophy of "if it compiles, it'll work" is beautiful and really helpful. But trying to get something to compile can get pretty frustrating at times, especially when coming to the language with a brain used to much higher-level languages — or languages that have no problem giving one heavy weaponry fully loaded, aimed at one's own feet.

So it can be painful. And slow. But I know there's a reason why the compiler mocks me, and I really want to understand it well enough to avoid the problems and get to taste the sweet benefits the language has to offer.

So I'm absolutely going to finish those remaining 93 exercises on Exercism and make sure I understand the main concepts of the language well enough to use it when I want to.