Hacker News new | ask | show | jobs
by keehun 1372 days ago
Does anyone have good resources to learning rust? I have a fairly good working knowledge of C, C++, and Swift.

I understand there's the Rust Book, Rustlings, and Rust By Example at https://www.rust-lang.org/learn. Are there other good resources? Does anyone have a strong suggestion on which of those official resources I should start with?

11 comments

Start with the Rust book. Then "Rust for Rustaceans" by John Gjengset is a fantastic resource to learn about more than just the basics. He posts hour long videos on his youtube where he explains the concepts that he mentions in his book. I found that reading a chapter and then watching one of his videos really taught me about /why/ the language is as it is, rather than just learning to get the compiler to be happy. (It also includes chapters about API design and what to look out for if you are going to publish your own crate)
> Does anyone have a strong suggestion on which of those official resources I should start with?

The rust book. Reading it start to finish provides a very good basis.

And if you're tempted to "learn by doing" with the usual linked lists, go and read "learning rust with entirely too many linked lists": https://rust-unofficial.github.io/too-many-lists/

Rust has enough rare or novel concepts that trying to learn on the job with no book learning whatsoever is really reserved for the rarefied few. Though I understand that a lot of C and C++ concepts port quite easily, it also differs from those languages (especially C++ for advanced features) that doing a bit of a reset will avoid future pains e.g. Rust's concepts of copy, move, references, ... are very different from C++'s and going in half-cocked will be frustrating.

If you‘re willing to spend money on a great book that teaches you all the basics of Rust, I can only recommend Programming Rust, 2nd edition (OReilly). It includes tons of examples, code snippets and is also a good resource for looking up stuff once you‘re done reading it. It also includes many passages comparing C++ with Rust, so that might be useful for you. It‘s a great book for anyone, who already knows a few programming languages. Programming beginners, should look elswhere tho.
A few things. The hardest thing about Rust is to forget many of tthe paradigms or aesthetical ideas other languages hammered into your brain. Programming Rust like you would program Python, Javascript or C++ is going to give you a hard time, but each time in a different way. If you program Rust in the Rust way, suddenly things become easy.

That means what the best way to start is depends on your background. In my eyes you can do nothing wrong with going through the rust book you already mentioned. Having read 4 different Rust books I have to say this introduction in combination with "Programming Rust" by Jim Blandy, Jason Orendorff, Leonora F. S. Tindall is probably the best way to get started. https://www.oreilly.com/library/view/programming-rust-2nd/97...

So, with "good working knowledge" of C++ and Swift, you probably aren't going to have too much trouble with the basics, if anything you might worry that there's some subtlety which you're missing when actually nope, whatever just seemed easy maybe actually was that easy.

[ For example move really is as simple as Rust makes it look, it is a headache in C++ because they added it to a finished working language ]

Several people suggested books/ web pages let me suggest some videos:

Jon Gjengset's "Crust of Rust" Youtube videos are good once you reach the point where you can write more than "Hello, world!" with some confidence but certain specific things aren't clicking.

https://www.youtube.com/watch?v=rAl-9HwD858&list=PLqbS7AVVEr...

For example, Jon does a whole video on lifetime annotations, which are something you won't see in most popular languages, but also one on Rust's iterators, which are a familiar concept from both C++ and Swift but don't work quite like either (they're very different from C++ iterators, your Swift experience will help more).

I recommend watching specifically a handful on topics you don't feel you understood well, although you could watch all of them especially if you just enjoy Jon's style and have the free time. They're not fast paced, if you wanted "Rust in 60 minutes" this is not that, but each one is actually writing carefully chosen code that runs and talking through what's going on, not just clicking through slides.

I think there's a missing book - 'Thinking In Rust'. The mechanics of borrow-checking, lifetimes, std lib, tokio can all be learned quite quickly. It's the muscle memory of techniques and design patterns that takes the longest to re-learn.
As you already know C and C++ this one is great: https://web.mit.edu/rust-lang_v1.25/arch/amd64_ubuntu1404/sh...

Just go through everything in "3 Syntax and Semantics" and "4 Effective Rust", you already know how to program C and C++ so that is all you should need to know. Took me a few days.

This is my journey so far:

(1) Go through the Rust Book,

(2) Do "exercises" (small side projects, advent-of-code, rustlings. ..etc),

(3) Go through "Rust for Rustaceans". It's specifically targetted at "intermediate Rust developers". If you have "good working knowledge" of C and C++, I will wager that you will absolutely love this book, because, to me, (1) it explained so much of Rust's design choices, and (2) you will learn so much so quickly.

I learned it combining the Book and Rustlings. There's a table in the exercises directory mapping the exercises to the chapters of the book, so I'd every day do the exercises for yesterdays chapter first before todays chapter to have some sort of spaced repetition. For more material, check out https://github.com/jondot/rust-how-do-i-start
I started with the book to learn the fundamentals. I didn't get very far before I decided to rewrite an existing API I had in Python into Rust.

It definitely took some time and learning but now I have 6 Rust API microservices, a few scheduled/queue-reading services, and a shared library for common models/utils/providers.

I enjoyed the rustlings puzzles. They reference the book a lot, and I tend to learn better by doing (at least a little bit of doing).