3 ms·
> We do the same for OS resources (handles, sockets, etc) and dont use automatic resource managers 1) Modern languages have made inroads here. 2) The OS is my
by mrkeen 2y ago
> We do the same for OS resources (handles, sockets, etc) and dont use automatic resource managers
1) Modern languages have made inroads here.
2) The OS is my automatic resource manager. When I hit ctrl-c on my running C program, my free() is never hit, yet it is cleaned up for me.
> So why complicate the design with automatic memory management?
I don't know beforehand who is going to be reading my memory, how many times, in what order, or whether they're going to copy out of it, or hold onto pointers into it.
> I just dont understand the fear with manual memory management. With RAII and and simple diligance (clear ownership rules), managing memory is an easy engineering task.
I claim that if managing memory is that straightforward, then it makes more sense to leave it to the compiler (Rust-style, not Java-style.) rather than let a human risk messing it up.