3 ms·
> From something with a ton of mutability, scope confusion, exceptions serving as GOTOs for business logic - into scala pure functions. The python was inscrutab
by js8 9y ago
> From something with a ton of mutability, scope confusion, exceptions serving as GOTOs for business logic - into scala pure functions. The python was inscrutable with a team of people treating it gingerly. The scala is easily refactorable and each time we take another crack at it, it shrinks into smaller and smaller code (and not by using crazy Scala) and I suspect that much of the confusing hairy complexity will disappear.
I have noticed the same thing with my Haskell code. In other languages with side effects, I often tend to write much more complicated procedures, with cross-cutting concerns. Haskell forces me to break it down more.
Maybe FP really is harder to reason about (and write), and that's why people have to write it much more clearly in more manageable chunks. But paradoxically, the net effect is positive, it's actually what makes it easier to reason about (and read) in the end. (And the separation of side effects makes a big difference here.)
> I don't really know how to quantify this
I was thinking about this. Maybe there should be some information theory framework that could capture complexity of functions (including side-effects). For example, compare how many bits of information enter on input, how many bits are potentially different on output. Then you would have a measure of complexity of individual functions.