4 ms·
OOP is an attempt to manage global state and the mutation of it, lenses are essentially a convenient way of transforming values (without mutation) and are only
by willtim 11y ago
OOP is an attempt to manage global state and the mutation of it, lenses are essentially a convenient way of transforming values (without mutation) and are only superficially similar. Side effects are inherently non-compositional, so it's no surprise that they are not easy to model, but Monads are gradually teaching us the best way to handle them. The current state of the art appears to be a single monad parameterized with an effect algebra (supporting composition for some effect types). You are of course free to be a skeptic, but in doing so you are rejecting a large part of modern computer science.
- paxcoder 11y agoCam you recommend some easy* literature to understand the things you're referring to? I'm interested in particular in things more flexible and easier to understand than the monad. *as in not written by and for mathematicians
- qubitcoder 11y agoPureScript comes to mind. It takes a hybrid approach to handling side effects (such as console IO, AJAX requests, random number generation, etc.). I'd recommend checking out Phil Freeman's article, which provides a nice overview along with many concrete examples [0]. Unless you've had prior exposure to Haskell, I wouldn't get too hung up on the syntax--but if you're curious, the PureScript learning resources are fantastic; I wish such resources existed when I was trying to learn Haskell! And frankly, these concepts require repeated exposure, practice, and some time to marinate in your brain before their usefulness/power become clear. [0] http://www.purescript.org/learn/eff/ http://www.purescript.org/learn/eff/ [1] http://www.purescript.org/learn/ http://www.purescript.org/learn/