3 ms·
> Agreed, OOP is orthogonally opposite of pure functional programming. Objects have state. Big revelation. I don't think that's quite true. Having state or not
by Twey 2y ago
> Agreed, OOP is orthogonally opposite of pure functional programming. Objects have state. Big revelation.
I don't think that's quite true. Having state or not isn't a dichotomy but a continuum about the size of the scope of the state. Objects (in either the Kay sense or the Java sense) exist to encapsulate state, to limit its scope and make it easier to reason about. That puts OOP (state is local to objects, and can be cleanly reset by destroying and recreating the object) somewhere between ‘pure imperative’ (only global state; there is no reliable way to reset the state) and ‘pure functional’ (state is limited to being kept in function arguments and return values, and is reset on each function call) on the continuum.