HACKER Q&A
📣 metadat

More pleasant and efficient Path to Learning Rust?


About me: I'm already proficient in C, C++, Javascript, and Scala. I'm expertly adept at Java, Go, and Bash.

I am sold on the idea of Rust, it's awesome. I've played around with Rust and love it conceptually and philosophically.

When I sit down to actually learn it or start hacking on something, I'm consistently put off and frustrated by the steep learning curve in terms of being able to read and understand Rust programs. The syntax is relatively complex compared to the other languages I know. Everytime so far I've ended up overwhelmed and given up in frustration.

This is just for fun, there isn't a professional driver pushing me every day to learn it.

I'm hoping for a better way than "just push through it over and over until it becomes familiar". Learning Go was a pleasure back in 2012, and I wish learning Rust felt similarly empowering, but sadly it's felt opposite.

What is the most efficient and ideally fun way to gain proficiency in Rust?

Thank you!


  👤 mplanchard Accepted Answer ✓
Probably an obvious question, but have you read the book? Even if you feel your experience with other languages should be enough to let you skip “beginner” content, I cannot recommend the book enough. Going through every chapter and doing the exercises should get you in a place where you can write rust relatively comfortably. From there I think Rust in Action is another good source of introductory material.

I also don’t know what you’re using for your dev environment, but whatever it is, make sure you’re using the rust-analyzer language server. The excellent and immediate inline warnings and errors are immensely helpful, even now with several years of rust experience under my belt.

I think it’s also really helpful to do a couple of small projects with limited scope, e.g. a single-threaded, literal match grep CLI, or `du` clone or whatever.

As Klonoar pointed out, also don’t beat yourself up over writing “good” rust, at least not initially. Don’t worry about cloning and unwrapping, and throw stuff behind an Arc and/or Mutex whenever shared access or mutation gets hairy. Taking that route, Rust isn’t more difficult to write than any of the other languages you know, and it’s fine while you build familiarity.

Also don’t hesitate to reach out on Rust’s zulip or discord, or the unofficial community on reddit. People tend to be very helpful.


👤 Klonoar
Stop caring about writing .clone() until you feel comfortable enough to care.

The biggest thing I see people go crazy with in Rust is trying to avoid cloning things. I've watched it block people from progressing in the language. Yes, you ultimately don't want to clone everything everywhere, but getting something built in Rust and then iterating backwards is often a better way to learn the language than trying to be "correct" from the start.

Cloning often removes any need to deal with lifetime signatures or what-have-you. If you're bothered by a full clone, grab Rc/Arc and use that trade-off in the beginning - it's not going to kill you. These changes make the syntax of the language fairly comparable to other languages.

tl;dr: .clone() things, measure if it's a problem, and then work backwards to the state you feel that the language/borrow-checker/whatever is pushing you towards.


👤 gaws
> About me: I'm already proficient in C, C++, Javascript, and Scala. I'm expertly adept at Java, Go, and Bash.

What language(s) will keep one employed for the next 50 years?


👤 malkia
I could never be proficient in C++.