Comment Re:Tiresome (Score 1) 782
Yeah my main language is C++... I don't really like GC. I know the patterns to not leak (ex: use reliable primitive containers and let their destructors do the work... slap anyone's fingers if they try to type malloc, free, new, or delete). I then have to go into C# and Java and its like... why... why did IDisposable turn out this way?
I digress.
Back to your point... I mean... everything should be a local variable. Everything should be owned by a stack frame that's somehow attached to main. Any heap allocations should be done by the container that's sitting at some level in the stack. Those containers have some API to access its contents. That's what OOP is good at.
Like... you don't say, "Hey table + 508 bytes, how are you?" You say, "Hey table -- what's in row 6 column 4?" and it gives you some view into it (reference, copy, whatever). That's OOP. It should be used as a parameter of a pure function that cannot affect any state (except logging) outside of itself, which is where the meaningful work will be done. That's Functional.
I digress.
Back to your point... I mean... everything should be a local variable. Everything should be owned by a stack frame that's somehow attached to main. Any heap allocations should be done by the container that's sitting at some level in the stack. Those containers have some API to access its contents. That's what OOP is good at.
Like... you don't say, "Hey table + 508 bytes, how are you?" You say, "Hey table -- what's in row 6 column 4?" and it gives you some view into it (reference, copy, whatever). That's OOP. It should be used as a parameter of a pure function that cannot affect any state (except logging) outside of itself, which is where the meaningful work will be done. That's Functional.