What to learn before learning Rust?

1 points by catlover76 ↗ HN
I am about to start learning Rust, but I don't have any background programming in C++, or anything else that involves thinking about memory management, and other such "low-level" concepts. My programming background is mostly Python, C#, and TypeScript.

What should I go about learning before learning Rust, so that I have the right mental model going in, so that I can both appreciate what Rust does and understand error messages I get?

3 comments

[ 2.9 ms ] story [ 16.6 ms ] thread
Just go for it and let the compiler tell you where you're wrong and guide you to something that compiles. If you can already program you'll pick up the other concepts in no time.

For example instead of taking a high level language view of a var containing a piece of data, you'll begin to visualize a variable points to a place in memory with data associated to it, and can work from there whether you want to move, borrow, or drop it. Lifetimes lets the compiler know how long should that point in memory last within the program before being dropped. But most of the time you don't have to worry about it thanks to lifetime elision.

"The Book" is the best place to start, then there's Rust by Example that shows code snippets. The Reference goes into the why. Rust for Rustaceans helped me understand how to put projects together, but if you like reading source code of different crates you'll see a pattern that they follow. Blessed.rs is a website for the most popular go-to crates in the ecosystem. Reading the std lib is also good to see what already exists instead of reinventing the wheel.

I came from an Elixir background so things like immutability and pattern matching already made sense. What great about rust IMO is the type system, programming with structs and traits, and knowing that if it compiles it should for the most part work if there's no logic bugs.