3 ms·
You manage memory in Rust about as manually as you manage memory in Python, at least in normal application code. If you do very low level stuff, you might thin
by DasIch 6y ago
You manage memory in Rust about as manually as you manage memory in Python, at least in normal application code.
If you do very low level stuff, you might think about that a bit more but then you have to in any case.
- higerordermap 6y agoYou bullshit promoting rust on hacker news about as easily as you write a program in python. If you do very meaningful shilling, you might think about that a bit more but then you have to in any case.
- 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.
- hu3 6y agoThis is exactly the type of claim that makes me read rust comments from a very uncharitable position. > You manage memory in Rust about as manually as you manage memory in Python
- steveklabnik 6y agoIt is the experience you have once you get over the hump. It is not the experience you have at the start. This gap causes a lot of arguing on the internet.
- umanwizard 6y agoThat just isn’t true. Rust certainly gets easier with time, but managing memory is absolutely not as simple as in Python. I’ve been using rust full-time for a year and don’t consider myself a particularly stupid person.
- steveklabnik 6y agoI have incredible bias here, but this is my experience. I never think about memory management in Rust. I write code, the compiler yells at me when I make a mistake, and then I fix it. There’s no huge amounts of time thinking about this at all. That’s the compiler’s job! 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.
- umanwizard 6y agoI would describe everything you described in your comment as “thinking”. Perhaps we were simply using the word differently.
- steveklabnik 6y ago