Ask HN: Are there any easy Rust tutorials out there?

10 points by mdwalters ↗ HN
I've not been able to grasp Rust, and I've looked through the Rust book, and Learn X in Y minutes, and still having difficulty confidentially learning Rust. Are there any easy tutorials out there for Rust that you've used in the past?

11 comments

[ 3.2 ms ] story [ 33.6 ms ] thread
Give "A half-hour to learn Rust" a try: https://fasterthanli.me/articles/a-half-hour-to-learn-rust

Books/tutorials/etc. never really worked for me because they were all "happy path" exercises (read: too boring). Things only started clicking when I had to overcome obstacles while porting projects written in different languages over to Rust.

There's a steep learning curve to the language. The key thing to remember is that you cannot have multiple mutable aliases to the same data.

The best thing to do is write enough code in projects you understand until the fundamentals click. Stay away from async until you get those, then why async is the way it is will make sense.

Try implementing something useful for you in Rust from scratch, without following a tutorial. Books will only get you so far.
this is literally the opposite advise that is generally given! Rust isn't considered to be a language that you can simply pick up, code in a style that is idiomatic in another language, and become Rust-idiomatic over time. (People who attempt this normally give up after trying to implement a linked list. Do not try to implement a linked list (or other self-referencial data types, that's advanced stuff in Rust)! So first read the book that try something, and now that Rust is hard to get into (apparently hard for C/C++-folk because they think they already know how this kind of programming, and therefore Rust, has to work). Since it's hard, you know that you're not doing anything wrong, when it feels hard. There aren't really any shortcuts since Rust is made off of several parts that work closely together, so you kind of need at least have heard about it (so read the book first). My advice: in the beginning it's ok to use clone() whenever you run into a lifetime issue. Over time while you get better, your usage of clone will decrease naturally. Check out: Learning Rust the wrong way https://www.youtube.com/watch?v=DL9LANLg5EA to see why the hard way is the fast way (at least in Rust).
He has already said that he read the Rust book, my suggestion is to start applying what he learned, not to read the next book.
> this is literally the opposite advise that is generally given!

It can still be a good advise tho. I was building a webrtc server in nodejs but decided to change it for Rust to learn. It was quite difficult! But now I'm starting to understand things that I don't understand in Rust and that spiked my curiosity much more than when I tried to study it starting by the theory.

Do it the long, slow way. Write and run every example in the Book, in order. It takes you from “hello world” to a multi-threaded web server. This is a long task, so spread it over a few days. Read the text as you’re coding to understand it and get the fundamentals down. The Book is really more of a tutorial than a reference.

After writing out the book’s examples, you will probably struggle with borrowing but after a few weeks of building things it will click. You will then face an overwhelming urge to write and rewrite everything in Rust.

A lot of good suggestions in thread so far. I'll take an alternative approach:

What are you having a hard time with? What are you familiar with, and what concepts are you getting stuck on?

I would treat it like other imperitive languages, and follow the compiler errors until you learn where to put the &s and *s. Stay away from traits, macros, async, and unsafe until you have the basics down. Running clippy will also teach you about available patterns.

Maybe stay away from map/filter/closures etc in favor of loops at first. They can have tricky syntax.