|
> In 2011 I observed that at the boundaries, applications aren't object-oriented. For years, I've thought it a natural corollary that likewise, at the boundaries, applications aren't functional, either. On the other hand, I don't think I've explicitly made that statement before. The next and last paragraph does not then explicitly make that statement, instead ending with: > Functional programming offers an alternative that, while also not perfectly aligned with all data, seems better aligned with the needs of working software. I think that's right. OOP is just a disaster, but FP is not. FP is not about making all of a program pure, but, rather, about isolating all the bits that can be pure (thus making them easy to test) and collecting all actual impurity into as small a bunch of code as possible. The impure code you end up having will look very procedural. In Haskell, you do this by running all side-effect-having code "in the IO monad", and monadic code looks procedural in the same way that PROGN loops procedural in Lisp though PROGN is [or can be] a macro that turns your procedural statements into one singular expression. So it's completely fair to say that "at the boundaries, applications are procedural", because, well, it's patently true! FP helps by helping the programmer push impure code as much as possible towards that boundary, leaving the rest to be as pure (and thus easily-tested) as possible. For example, if you have code that uses the time of day for externally-visible effects, then pass it the time of day so as to make it more pure and easier to test. This one is counter-intuitive because we like to just get-the-current-time, but I've done this to make code that does epochal cryptographic key derivation deterministic and, therefore, testable. |
Why does nobody appear to be having runaway success with it, if it is the superior paradigm?