7 ms·
> You manage memory in Rust about as manually as you manage memory in Python, That's not true in my experience. Every single error the borrow checker throws at
by perryizgr8 6y ago
> You manage memory in Rust about as manually as you manage memory in Python,
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.
- DasIch 6y agoI admit that this is to some extent memory management that you have to think about. However especially when it comes to concurrency, this is stuff you have to think about in any language. 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.
- ufmace 6y agoI haven't written a huge amount of Rust, but I feel like I understand it well enough to not have much of an issue with this. It seems like what Rust really want you to think about is not so much memory management directly, but ownership. 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.