If you do very low level stuff, you might think about that a bit more but then you have to in any case.
If you do very low level stuff, you might think about that a bit more but then you have to in any case.
That's not true in my experience. Every single error the borrow checker throws at you is in a sense "memory management". Rust forces me to think very hard about memory, in all but the simplest toy programs.
You want anything to do with threads? Gear up for a long afternoon of fighting the compiler before you fully understand your memory model and use it properly. You want anything to do with linked lists? Same deal. You want anything to do with async. Plan to spend 3 hours just to figure out what you want to really do.
All this is memory management. Just in a different form compared to C/C++. Python OTOH simply lets you forget that the computer exists. It's just you and the problem you're solving. You pay for that with lack of speed and bloated memory usage.
The difference is just in when you get the error and what kind you get. Do you get errors at runtime or does the compiler complain?
I would argue that doing some of this in Python with no language support at all, is in some ways more manual than Rust, where you get at least assistance.
Ownership and borrowing in Rust is solving a much bigger problem than what has been traditionally understood as memory management. Put another way: Other languages even with GC only solve memory management partially.
Rusts approach has downsides with cyclic data structures, that’s true but how often do you implement those in real world code? Async can indeed be tricky, that requires a bit of time to wrap your brain around but I think it’s getting better.
Linked lists? Rust just really doesn't like them. Better to use something else instead. I can't remember ever wanting to use a linked list in a program I've written though. I think you could argue that it's tough to write a linked list implementation that really never leaks memory without a GC.
Threads? I'd argue that the stuff that Rust prevents are usually real bugs. You might not hit those bugs right away, especially in a language with a GIL, but they're there. Better to know they'll just never happen, no matter how hard you push your threads.
For async, I guess I've had good luck with it so far. I still feel like I don't really understand what's going on with Rust async and runtimes, but most of the code I've written with it just works.
> You manage memory in Rust about as manually as you manage memory in Python
Like, last week I wrote some code that had a use after free, because I wasn’t thinking. I wasn’t thinking because I didn’t have to. The compiler thinks for me. It told me my mistake, I immediately fixed it and moved on. This was like a ten second process. “Oh yeah that takes ownership but I wanted a reference, toss an as_ref on it and move on with life.”
I do have a lot more than a year though.