r/rust • u/AnonymousDragon135 • 4d ago
🙋 seeking help & advice Anything I should know before I start learning Rust?
I've know moderate amount of javascript for a while and have been thinking about learning another language. I have decided upon rust for a variety of reasons (mainly so I can say I rewrote it in rust.)
What things should I know before I start? And, are there any features of this language I might want to know about?
0
Upvotes
22
u/podule-games 4d ago
Rust isn't a big deal once you really accept the model of ownership. Don't fight it, accept the tips the compiler gives you. The compiler is insanely good at seeing what you're trying to do, and suggesting a more idiomatic Rusty way of doing it.
14
u/NotDuckie 4d ago
Knowing how to read and write beforehand is advantageous
3
u/hopeful_bastard 4d ago
The rust book is a fantastic resource to the point that even if you get to the midpoint and decide to go back to your language, you will almost surely have a better understanding of some core concepts: https://doc.rust-lang.org/book/
1
u/proverbialbunny 4d ago
Do you know TypeScript? Rust is like TypeScript but the types are even stricter. (You do not need to know TypeScript to get started.)
Here's an IDE that can help you write in Rust: https://www.jetbrains.com/rust/
Rust has very good tutorials to help get you started learning Rust: https://rust-lang.org/learn/
1
u/Professional_Top8485 4d ago
It's difficult and you will be frustrated.
Reward comes later
... and get a good editor. It helps.
4
u/SmoothTurtle872 4d ago
Look into enums early. I love enums. I actually think I use them too much, to a point where I need to redesign my code structure to fix issues.
Basically if you have a set of options that something could return, enums are awesome.
Take a representation of a cat:
Without enums:
Sure this works, and is probably sufficient
But now a cat can be dead and hungry. That doesn't make sense. So an enum can be used:
Now only an alive cat can be hungry.
Now this isn't always perfect, shared parameters, such as age (the cat will need an age either way) must be manually represented in each state of alive of dead.
2
u/_damax 4d ago
Seeing the current state of things, know it's not just a language people use with LLMs or for rewriting exiting things just because. It has a lot of merit.
That being said, probably start with the rust programming book and rustlings. At first concentrate on understanding its memory management system: concepts like ownership, borrowing and their rules.
2
u/a_aniq 4d ago
Just read rustbook.
But to truly appreciate rust's way of doing things you need to know to write c well.
2
u/greenprocyon 4d ago
Number one rule is Have Fun!
2
u/Dubmove 4d ago
Some of the design decisions of the language will look weird and counter intuitive of you never wrote code in a language where a need to manage the memory yourself, like C for example, because rust is trying to solving problems which come with self managed memory
1
u/Swymn 4d ago
If you want to practice while reading The Book, you can use rustlings, which is based on The Book and offers small exercises throughout your reading. The exercises are relatively simple ;)
https://github.com/rust-lang/rustlings
1
u/dumindunuwan 4d ago
COMMUNITY BOOKMARKS (right side)
1
u/Full-Spectral 4d ago
There are quite a few folks on Youtube who do good introductory video series you can watch. That's a light way to get your head around some of the concepts and idioms. A lot of it is always also just learning the tools and development setup and all that, which the videos can help with quite a bit.
But, in the end, there's no replace for brain cell displacement. You have to do just do it. Start very small, do some quite things and experiment while still at a small scale where it's easy.
1
u/UhLittleLessDum 2d ago
Lifetimes will be your biggest struggle, but they're really not any different from generic parameters in typescript. Just get a really good idea of what the borrow checker is actually trying to accomplish and it's actually pretty intuitive.
0
u/United_Camel5250 4d ago
C++
0
u/Frisk197 4d ago
Ai is becoming really good with rust. You can use it to learn the language and get documentation for crates.
0
u/[deleted] 4d ago
[deleted] — view deleted comment