3 ms·
I've been learning Rust officially for about a week. I wish this had made it on hacker news last Friday! I'm learning by making a little MVC framework with cgi
by earlz 13y ago
I've been learning Rust officially for about a week. I wish this had made it on hacker news last Friday!
I'm learning by making a little MVC framework with cgi-bin (eventually it'll be portable to rust-http and elsewhere..). The best part about Rust is that in 99% of cases, if your "logic" is right, and your code compiles, everything will just work and run properly. Unlike in C where your logic may be right, but your pointers wrong, or in C# where your logic is right, but that threw a null reference exception, etc.
The hard part was that I tried writing Rust like I do C#. Using garbage collection elsewhere. The biggest hurdle is that when you're designing your structures you must not think just about what they need to access. You must also think about the ownership of what they access, and the ownership of what will be using it.
After finally refactoring and figuring out my ownership model, turns out I didn't even need garbage collection or reference counting. Everything could go onto the stack save for some vectors and mutable strings
- steveklabnik 13y agoHopefully future new learners will have it easier. :) If there's anything else that's confusing that could use elaborating, let me know.