2 ms·
I don't claim to be very experienced in functional programming, but doesn't his whole argument simplify to "State is hard in a pure functional setting" ? I was
by tensor 17y ago
I don't claim to be very experienced in functional programming, but doesn't his whole argument simplify to "State is hard in a pure functional setting" ?
I was under the impression that this was a simple and fairly well understood problem. Either use a functional abstraction for state, a reduce with state or perhaps a monad if the state needs to be carried through many types of operations, or manage it in an impure way, using STM with a global state perhaps.
I don't see how this is any knock against the functional programming paradigm. I always understood the rule of thumb to be "use purity as much as possible, and be impure only when it's explicitly needed." Modifying a global state seems to be a pretty obvious case for using an impure function.
Am I misunderstanding this?
- statictype 17y ago>I don't see how this is any knock against the functional programming paradigm. I always understood the rule of thumb to be "use purity as much as possible, and be impure only when it's explicitly needed." Modifying a global state seems to be a pretty obvious case for using an impure function. This is pretty much exactly what he's saying. His response was targeted at people who think functional programs should wholly avoid state and side-effects. (I don't actually know of too many people who believe this, but apparently he does)