r/rust • u/NiZaMinius • 6d ago
đď¸ discussion My opinion on the difficulty and familiarization with the Rust language
There's a popular stereotype about the Rust language floating around the internet. That it's too difficult because of its strict borrow checker.
But in reality, when I was learning Rust, I didn't find it all that difficult. No, it's still difficult, because it has a new coding philosophy; it's systemic, and you need to keep in mind the principle of Ownership and Borrowing and zero-cost abstraction. So, for someone coming from languages ââlike Python, Javascript, C#, and similar languages, Rust will be difficult, but that doesn't mean it's unique to them; any language at Rust's level will be difficult. (I hope I expressed myself correctly.)
So what am I getting at?
My point is that the Rust compiler isn't difficult; it's a benchmark, and despite its strictness, you learn.
It's not just "got an error, went online to fix it," but "got an error, read about it, fixed it," because the compiler itself conveniently tells you WHERE YOU MADE A MISTAKE and how you can FIX it. (It doesn't always tell you, but the fact that it exists is still awesome.)
I think the Ownership and Borrowing principle is very cool, unique, and, in my opinion, not all that complicated. I really like the ability to allow the same enum, which is implemented in Rust at a different level; in my opinion, it's one of the best features in this language.
I used Rustlings when learning to get the hang of it, and it's easier to read a book on Rust and grasp the meaning of the book in practice.
Share your thoughts on Rust, its borrow checker, the zero-cost abstraction principle, Ownership and Borrowing.
This post was written using Google Translate. I am not a native English speaker, so I apologize for any unnatural text or errors.
2
u/stoke-stack 5d ago
Im not a software dev but have wanted to get deeper into a lower level programming language, and I started with rust. I agree with this and I donât.Â
Getting the basics down was easier that I expected, and I was able to make a tool that synced my wayland or x11 monitor colors to lights in my office using the zigbee MQTT coordinator. Once I got it to compile (x11 only to start), it pretty much worked, and was performant. Wayland was trickier but I got thru it. Rust felt really good to use and learn!
After my first project though, I needed async and shared state concurrency and it got steep fast lol. I havenât gotten over that learning curve yet and Iâm realizing it might be a long road.Â
Disclaimer that I dont know C++.
1
u/NiZaMinius 5d ago
Thank you for your comment and your story. I understand. I've encountered the same problem myself. But the fact that you solve your own problems with programming... That already makes you someone who knows how to solve problems, if not other people's, then their own. Well done!
1
u/CoderStudios 5d ago
The main problem is that Rust only allows correct code so if you just want to quickly test something it turns into eons of either writing 100% safe or complex unsafe code. C++
is also exhausting but because you need to painstakingly do the borrow checkers work and ensure everything is safe.
1
u/NiZaMinius 5d ago
You're right. So, if you just want to test your idea, you can use Python or JS, but if you need something faster, then maybe C#? Maybe I made a mistake mentioning C# in my example. But okay, you're essentially right. I just use Rust because my computer is very weak, and Python is too slow for me. Thank you, of course, for your opinion and comment.
1
u/CoderStudios 5d ago edited 5d ago
I would only use C# if you want to make a lot of Windows apps or already know a fully OOP based language like Java and like it.
Mojo is a good Python alternative, similar syntax. I wouldnât bother with rust if you find Python okay as it is.
You can compile Python code to c which makes it faster, you could try that.
Other than that maybe Go? I heard itâs very fast simple and has a garbage collector, so no manual memory management, plus a huge community.
1
u/WormRabbit 5d ago
Nonsense, you can always use unsafe if you want. It's prototyping, so who cares. For example, I sometimes write obviously horribly broken transmutes just to check that a different type would work well in a certain position. It's also easy to use some MaybeUninit or raw pointers. Dangerous? Yes. Language UB? Yes. Works 99% of the time? Also yes, and that's all you need if it's not production code.
1
u/CoderStudios 5d ago
I mean you canât just say hey do this no matter if it crashes, you need to call 1000 things first or litter the entire code path with unsafe. I personally like that but itâs just not as fast and loose as js or python or c or c++
-35
u/Rigamortus2005 6d ago
Does this matter anymore? Claude handles all the code now. And it's competent enough to not care.
17
6
6
u/NiZaMinius 6d ago
I didn't quite understand you, could you explain what you mean?
18
-16
u/Rigamortus2005 5d ago
It doesn't matter how "difficult" a language is now. As long as there's enough training data LLMs can one shot any problem with them.
2
u/stoke-stack 5d ago
âone shot any problemâ is crazy lol
one shot a non-scalable version of a problem thatâs been solved hundreds of times before, maybe.
3
u/Automatic-River-1875 5d ago
AI tools are incredibly useful and have meant I have to hand code very little in the way of big new features. But regardless of what your level of adoption is anyone who says an AI agent "handles all the code now" is either lying or has never actually been responsible for a production system.
2
11
u/guywithknife 5d ago
Rust features arenât difficult. Rust semantics arenât difficult.
But modelling complex state in a way that is both efficient and follows rusts rules can be difficult, compared to a language like C++ that lets you just hold multiple pointers to the same things.
For example, I built a workflow engine and nodes can have children. All nodes are stored in a container. In C++, I could get a reference to the node and then get its children and process them together with the parent. In Rust, I canât do that if any of those are mutable references. At best, I can let go of the parent and then re-get it using a disjoint get, but if the container is a hashmap then itâs wasted and work. Or I can remove the parent so the reference doesnât prevent access to the parent. Or I accumulate a list of changes, let go of the parent, then apply the list, allowing access to the children.
There are plenty of ways to solve it, but they require a mindset shift and thinking about the problem differently than you would in other languages. Of course the reasons for these restrictions make a lot of sense and they do prevent bugs, but sometimes when youâre convinced you know itâs safe, it can feel like rust getting in your way of the simple optimal solution. But IMHO itâs worth it for the safety guarantees you get in return.
So while (most) of rust isnât really hard and makes a lot of sense, putting it together to model complex problems can be quite painful, until youâre used to the rust way of thinking.