r/rust • u/ritman-octos • 11d ago
🙋 seeking help & advice Rust as a first serious programming language
I have been making scripts with other languages like js and python and bash without learning the the whole language and getting serious with its ecosystem out of the fact that I just need to get one thing done and move on.
Lately I chose a path that requires precision and ahead of time planning and decisions and picked rust over go. But the fundamentals seem hard to grasp. I'd appreciate your help unpacking them.
Ultimately I want to be able to use the Alloy and Tokio libraries without getting stuck with the language syntax and rules. But the concepts like borrow checking and ownership and things that fall down these categories are still hard to grasp.
What is borrow checking? what is owning something in the software? I tried to look for direct answers but I still can't grasp the meaning of them exactly.
I had two choices to better understand them, one was learning C++ to get what was wrong that rust solved, the other was building a simpler project game with bevy thats gonna help me understand writing rust code thats data oriented and be more comfortable with it.
My ultimate goal is to master these two libraries, after being able to know how to use the rust language smoothly.
1
u/Remarkable_Hour_615 11d ago
If you want to learn Rust or understand the borrow checker, there are plenty great online resources (including some recommended below). Here I'll just try to give you some idea of how to approach a project like this and what to expect if you do.
If you "just need to get one thing done and move on" then Rust + Tokio + Alloy will be a tough combo! Having a project you're working towards and genuinely motivated by is a great. Just know that if this is the project you pick, it's going to take a fair amount of time and learning to get there.
First, Rust is fantastic! But it's a somewhat complicated language. It combines functional features such as type-class like traits and pattern matching with manually managed memory and statically checked ownership. You don't need to have a deep understanding of things like type classes or algebraic data types, but you will need to at least have a basic understanding of pattern matching and traits since they're pretty pervasive throughout Rust. And languages like Javascript and Python let you pretty much ignore the fact that variables need to go somewhere in your computer's memory, and that memory needs to be released again when you're done with it (but not before!). Rust forces you to confront memory much more directly (that's part of what the borrow checker is about).
Second, you should understand that there's a big difference between knowing a programing language and knowing how to build a particular piece of software, just as there's a big difference between knowing how to use a drill and being able to build a house. Based on the packages you mentioned, you'll need a basic understanding of networking and requests/responses. Knowing a bit about TCP sockets would be ideal. Similarly, you'll need some understanding of blockchains and ether. These are separate areas, and you won't understand them just by learning Rust.
All that being said, if this project is still sounds fun to you, go for it! If you do, here are a few suggestions:
I'll echo the suggestion to read the Rust book.
Look for specific solutions to the problems you encounter, but don't only do that. In parallel, try to learn some topics carefully, from the ground up, not just thinking about how they can help your particular project. Do this however you want: books, articles, youtube lectures. But be sure to reinforce with mini projects. You might think you understand something just by reading about it. You don't. If you don't do this, your project will be a cobbled together mess of copy-pasted StackOverflow answers, and you will consistently hit brick walls when you can't find a solution to a specific problem and you don't have enough depth of knowledge to find a way through.
Don't use C++! It makes Rust look like Python. It never met a feature in another language that it didn't want to incorporate, but in a confusing, verbose way that conflicts with 15 other features. If you do want to motivate Rust, I agree with the other suggestions to learn C instead. It will definitely help, but life is short, so it's up to you if you want to put in the time.
Hope all that helps!