Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: More pleasant and efficient Path to Learning Rust?
12 points by metadat on May 3, 2022 | hide | past | favorite | 11 comments
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!




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.


What is "the book"?


Highly recommend. It's a great overview of Rust's ownership model and how to use things properly like enums and traits. Steve Klabnik is one of the authors if I recall correctly and he's been such a great resource for learning Rust. He lurks on HN as well and whenever you see a well written Rust comment, it's probably him.



Thanks for linking! I should have been more specific.


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.


I appreciate you replying!

How does this map a path from zero to proficient?


You're not starting at zero. You have proficiency in other languages and are probably good at them!

It's often about getting to a point where you're used to cargo/Rust borrow checker stuff/etc. Removing the lifetime syntax stuff makes it much easier to transpose your existing knowledge and rapidly get up to speed.


> 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?


I could never be proficient in C++.


How's your Rust?

I forgot to mention Python, it's one of my top favorites and quite good with it after 20 years. Easy language.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: