20
votes
Experienced programmers who picked up Rust, which learning resources did you find to be excellent?
I am currently going through the official Rust book and have gone through some of the Rustlings exercises. Both resources have been excellent so far.
What resources have you enjoyed?
Additionally, is there anything about Rust that particularly caught you out when transitioning from other languages?
Through examples in library crates. Once I had projects I wanted to do, I would usually start by looking up which library crates I'd need. Rust crates often have excellent documentation with examples, and I learned a lot from those.
For example:
Also, running
cargo clippy
regularly is a great way to unlearn common bad habits.+1 on Clippy. Some of its lints are very annoying at times (you can disable them one-by-one if they are bothering you), but overall I feel it has kept my code quite clean.
Also I love rustfmt, it's probably one of the few code formatters that I don't really disagree with.
The entire Rust toolchain is awesome actually.
This is not something I'd considered but makes total sense. Thanks for linking some examples too.
I'm still struggling to consider myself "experienced" despite working in the field for 2 years and doing personal projects for over 5, but anyway :)
The Rust book was awesome to get me started, and I felt I was able to start working on anything right away. Then as I started to create stuff, browsing each crate's documentation (either through docs.rs or through VS Code's tooltips) was enough to put things together. The rest was learned through practice, like with anything regarding programming.
Besides that, I did skim through Rustlings and Rust By Example, but I can't say I haven't read them entirely.
(And of course, nowadays a healthy dose of ChatGPT doesn't hurt, although this past month it had some embarassing fails for me with writing and refactoring code; caution is advised)
EDIT: Regarding things that caught me out (or surprised me), I had a rough time understanding trait objects. And pretty much all OOP-style concepts in Rust were a bit difficult to learn because they're trying to avoid as many problems common in C++ and C# as they can, but with some practice I've got the hang of them (at least for my purposes).
I have a background in C++ and some functional languages (e.g. Standard ML).
I'm trying to learn Rust right now for a personal project:
I read them both before writing any code, but have found it helpful to return to specific sections as I've had questions about more specific stuff (how does module discovery work, default visibility of struct members, etc...).
Rust also has a really healthy community of people who write about the language. Andrew Gallant (author of ripgrep) wrote a post on error handling that I found helpful.
Going in, I assumed that the ownership model would be my primary barrier to profiency. Turns out, it was easier for me to internalize that I expected, partly because of some parallels I see with C++.
Learning how to write "idiomatic Rust" has been the harder part of the experience, specifically relating to:
Trait
system has been forcing me to unlearn some of my default design patterns.String
vs&str
: I have a really bad habit about thinking about optimization before I need it. I've caught myself spending too long choosing between the two or trying to figure out how to accommodate both when I should've just picked one that works and iterated on the design if I realized I needed to later.?
everywhere to return on error, should I prefer.expect
orif let Some(...)
, etc...) .Reading through large codebases has been my primary way of looking for "idiomatic rust":
As someone who was very familiar with many more languages (C++, C#, Python etc.) I really liked Programming Rust. The Rust Book was a bit too basic for me.
I can't call myself an experienced Rust programmer, I mostly write C# these days, though I've used C/C++, Nim, Python, JavaScript, and some others in the past.
I had a really hard time grasping some of the concepts in Rust, but what actually helped it click for me was Rust By Example -- Sounds like a "duh" moment, since it's probably the most recommended source for new Rust programmers, but having detailed explanations as well as code blocks that could be run in-browser helped me out a lot. I especially liked that I could tweak the code on the page and run it again to actually see what changed.