Skip to content

Comment on Memory Management Referenceparent

Comments

pcwalton is right. RAII is just a language semantics to make memory management implicit.

(I feel a little bit cynical today and will say it's typical to C++'s attitude (as opposed to e.g. C): Let users make overcomplex programs more easily, by papering over all the insanity, instead of forcing them to make a clean design).

If there's anything like "memory management" in RAII, then it's the idea of deallocating objects in the reverse order of their allocation. That hardly deserves a note, though, since it doesn't say anything about how the memory is allocated.

(And as usual with OOP, you end up with terrible inefficiencies (too much allocation in this case), since the program is split into needlessly isolated parts in a futile attempt to make them "self-contained". In the end, what that does is also make everything less efficient and more complicated. And redundant, if you care to look at what actually happens as opposed to what the programmer writes).

And as usual with OOP, you end up with terrible inefficiencies

That is not a property of OOP. Counterexample: C++ is OOP and it's not inefficient. It's a property of having no control over the memory layout and no stack allocation. If Java gets value types it's efficiency would massively increase while still remaining OOP.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.