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?

7 comments

  1. [3]
    talklittle
    Link
    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...

    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:

    • A GUI application led me to gtk-rs which has plenty of examples and open-source applications to learn from.
    • A Discord bot could be written using the Serenity crate, which again includes plenty of examples.
    • Wanting to use Rust in a mobile app for iOS and Android led me to Mozilla's blog posts on the topic (iOS, Android).

    Also, running cargo clippy regularly is a great way to unlearn common bad habits.

    10 votes
    1. arqalite
      Link Parent
      +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,...

      +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.

      3 votes
    2. bugsmith
      Link Parent
      This is not something I'd considered but makes total sense. Thanks for linking some examples too.

      This is not something I'd considered but makes total sense. Thanks for linking some examples too.

      1 vote
  2. arqalite
    (edited )
    Link
    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,...

    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).

    4 votes
  3. zoroa
    Link
    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: The Rust Book is probably some of the best introductory...

    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:

    • The Rust Book is probably some of the best introductory learning material out there. The current edition at times feels very "beginner", so I've found it helpful to read the old version of the book.
    • Comprehensive Rust is a course by Google that also provides a pretty good language overview.

    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:

    • Application/api design without inheritance: Inheritance has been the crutch I could lean on in almost every language I've used extensively. And very much was the way I approached solving problems that were not trivially small. Leveraging the 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.
    • Error handling: In a lot of languages (e.g. C++, Python, Java, etc...), you can just let exceptions fall through the call stack until you get to a function that cares to handle it. In Rust you must make a decision for handling errors when calling a function that can fail. I don't yet feel like I have the right reflexes and idioms for error handling in Rust (Should I default to adding ? everywhere to return on error, should I prefer .expect or if let Some(...), etc...) .

    Reading through large codebases has been my primary way of looking for "idiomatic rust":

    • helix - My current text editor, and my first modal one.
    • ripgrep
    4 votes
  4. gadling
    Link
    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.

    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.

    2 votes
  5. Leftbones
    Link
    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...

    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.

    1 vote