3 ms·
> The table is there to summarize things discussed, but he never says he wants to do manual memory management. But it requires me to manage memory and lifeti
by ignoramous 1y ago
> The table is there to summarize things discussed, but he never says he wants to do manual memory management.
But it requires me to manage memory and lifetimes, which I think is something the compiler should do for me.
The author wants the compiler to do memory management? How does Rust achieve this?
- steveklabnik 1y agoThe compiler works with you to ensure that you’re not misusing memory. If you make a mistake, it will let you know. You’re not often manually managing memory in the same sense as other low-level languages. You’re not invoking malloc and free directly. Thanks to ownership, when you do allocate, Rust will call free for you. It’s somewhere in between fully manual and fully automatic. It can feel more like one or the other based on what you’re doing, but most of the time, in average, it feels like automatic.
- adastra22 1y agoIt is better to think of Rust having explicit memory management, rather than manual memory management. C/C++ has manual memory management: the burden is on you to do it correctly. If you fuck up, your program will have bugs. Rust requires that your code be explicit about memory issues, but the compiler works with you to achieve that. if your code compiles it is correct; if it doesn't compile, the error points out what needs to be fixed. When I write Rust it rarely feels like I am taking on that burden myself.