3 ms·
What is the best way to pick up Rust and its best practices as of today? References welcome (thanks in advance!)
by srvmshr 4y ago
What is the best way to pick up Rust and its best practices as of today? References welcome (thanks in advance!)
- staticassertion 4y agoWrite some code, listen to the compiler's feedback, don't worry about "good" or "fast", just get things working.
- ArchOversight 4y agoThe Rust Programming Language book is absolutely fantastic: https://doc.rust-lang.org/book/index.html https://doc.rust-lang.org/book/index.html It's a pretty quick read and gives you a good handle on Rust fairly quickly.
- olalonde 4y agohttps://github.com/rust-lang/rustlings https://github.com/rust-lang/rustlings
- pizza234 4y agoI think this (education) is a lacking area in Rust. You can read the reference book, and even a few other ones, but still not being able to have a sufficient/solid grasp of the language. I couldn't find good material past the beginner stage (I consider Rust for Rustaceans advanced). My personal advice is to find some project you'd like to implement, and practice a lot, or contribute to small projects you like, without worrying about best practices. There have been definitely many moments where I wanted to close the Rust chapter, and that's why I think it's more important than other languages to keep the motivation high, which I think is best achieved by working on projects. Rustlings is nice but... not stimulating.
- ttfkam 4y agoMy advice is to avoid optimization like the plague while learning Rust. Don't worry about extra copying or optimizing lifetimes or any of it. Make all the "extra" structure and String copies. Doing it the "basic" way is sooooooo much easier, which is important while learning. Nine times out of ten it will be fast/efficient enough anyway. After you've got a handle on it with a few non-trivial programs under your belt, then start tightening up once you have the necessary context and familiarity.
- jgerrish 4y agoThis is fairly good advice, but I've run into a few cases where codebases don't "optimize lifetimes" and you're left with static lifetimes everywhere. Which is ok for some use cases, but it's a core language concept. One that is confusing unless you work with it some. While the Rust syntax around lifetimes can be confusing, The Rust Book does a decent guide describing what lifetimes are. Reading up on Modern C++ practices and language constructs actually helps with Rust too. The rustdoc book doesn't have a lot of examples of the full markdown support for documenting your code unfortunately. Browsing through std helps. Cargo rocks, and it's easy to spin up a new project. One thing I did was create a few new ones just for concepts that were difficult to me at first.
- nu11ptr 4y agoI found the O'reilly book, "Programming Rust" 2nd edition, to be the best book. It is long but thorough. "The book" might be a better starting point, but is less thorough I thought, and while it left me feeling more like "I got this", I didn't think it prepared me for "real world" Rust quite as well as the O'reilly book.