by kstenerud · 2y ago · 0 comments
State is dangerous - it's an entropy multiplier, so keep it within reason and for gods sake don't ignore it or pretend it doesn't exist.
We like to think that we have it all under control, but the time dimension multiplies everything, and has a tendency to ratchet them until suddenly you find that you actually don't have it under control anymore.
The less state you have, the less your brain gets turned into a pretzel trying to keep track of it all over the time dimension.
A complex application will probably have more. An easy application will probably have less.
If the modern web has taught us anything at all, it should be that trying to fit small pieces of state together like a puzzle ain’t it.
We have enough to make a discipline out of the field, but every 20 years or so the next generation of fresh recruits brings all their bad habits in with them and then round and round we go again with the new (and horribly broken) technologies that didn't learn from the last time we did the same things and made the same mistakes in a similar way.
You absolutely can control how much state you need (down to a minima, of course). The issue is not with the minimum state necessary - it's with the cowboy mentalities that lead to excessive state (and even worse - excessively complicated state interactions).
That being said, functional verification is a huge time sink and is really only economical if it's very important for the code to always be correct. That is, people die if your software has a bug. A few examples would be pacemakers, aircraft autopilots or your car brakes.
If your not working one of these domains then maybe immutable and pure functional code can save you a few bugs? I have not read any peer reviewed study that shows this is the case. But if you have any such paper i would be happy to read it.