Learning roadmap

I have been programming for a long time in a lot of different languages, mostly procedural and object-oriented ones, but also experimented a bit with Haskell. Learning Rust was particularly hard for me, and I gave up twice, until I finally went through with it in my third attempt.

A couple of lessons I learned (or rather: had to learn):

  • Structs like Cell, RefCell, Arc, etc. are seldom needed, but if you need them, it does help if you already know them well (and know how to use them). So if you start learning with The Rust Book, don't skip these topics.
  • There are often multiple possibilities to design an interface: do you pass a certain value by moving (transferring ownership), expect a reference (and possibly return a result with a newly generated datum), or expect a mutable reference (and modify values in place)? After playing with these options a bit and taking a look at other libraries, it felt like the best choice is most often the choice with the least effort for the callee.
  • Sometimes Rust's standard libray offers certain functionality in a limited way only. It's good to be conservative (i.e. reluctant) about which functionality is added to the standard libraries, so that's not a critique. But for example, I quickly ended up with "rayon" instead of using Rust's built-in threads. It's not always easy to decide which library to pick for a particular task (I try to avoid adding too many random dependencies to my projects). Websites such as The Rust Cookbook may help.
  • Calling methods of traits that aren't imported with "use" (or included in the prelude) aren't in scope and can cause a compiler error. This is actually great because it avoids collisions in the namespace while allowing types to implement multiple traits instead of having a restricted class hierarchy. But it can cause confusion sometimes as you may have a value but can't call its methods (unless you import the corresponding trait as well).
  • It may help to read compiler errors carefully. The compiler errors are pretty helpful in many cases and often give hints how to solve a problem.

I'm sure I've missed some points. Working with Rust sometimes can be irritating if you're new to some concepts, but I feel like it totally pays off. I don't want to miss Rust anymore.

People on this forum have been very friendly in helping me with questions that I wasn't able to solve on my own. Thanks for that :slight_smile:

1 Like