2 ms·
To be fair, there is some material there not related to GC; like about inconsistencies between built-in types and classes and whatnot. The rant about OOP and r
by kazinator 9y ago
To be fair, there is some material there not related to GC; like about inconsistencies between built-in types and classes and whatnot.
The rant about OOP and responsibilities is completely way off mark.
It is not a firm rule of OOP that a module has to clean up all the resources it allocates and never pass any of them off to be cleaned up elsewhere.
This is violated all over the place with layering. For instance, instead of allocating a buffer here and then having someone free it, we can create a Message class which has a buffer. We now send a Message from one module to another. Oh, the buffer is now a single responsibility: it is allocated by the Message module and freed by the Message module. But all we have done is wrap the resource in a trivial class; the design hasn't really changed. We can have a semantic leak if we start creating Messages and stuffing them into some queue which nobody dequeues, just like with the original buffers.
Layering of ownership creates the appearance that one module is managing a resource. That module's instances, though, can be created by one higher layer module and released by another.