3 ms·
> There is nothing about OO does enforce higher memory usage compared to other patterns. Many OO languages offer dynamic/virtual dispatch of methods as a prima
by pkolaczk 4y ago
> There is nothing about OO does enforce higher memory usage compared to other patterns.
Many OO languages offer dynamic/virtual dispatch of methods as a primary (and sometimes only) way to do polymorphism. This comes at a non-zero memory cost, because each object needs some additional runtime type information.
> In fact it might be better than functional programming, which relies on a lot of closures (which all need heap allocations)
Closures do not need heap allocations. Rust has closures and allocates them on the stack (unless you deliberately box them). I don't know Haskell, but I believe it could do the same.