Indeed, any stateful program will be at risk of persisting a bugged state. This leads to the uncomfortable realization that one of Erlang’s core ideas is probably wrong, or at least inadequate for large swaths of real-world programs. Aggressive correctness testing (FoundationDB is a good example) is a more fruitful path to ensuring that such states are unreachable.
Another fruitful path is to structure your code in such a way that bugged states are less likely to arise. Programming in a declarative style, where the program rebuilds its state by re-executing itself from the top rather than transitioning between states through piecemeal manipulation, is a helpful strategy. OTP supervisors offer a form of this, but they are fairly primitive. React’s engine is a much more sophisticated tool in this area, as it allows for stateful components with incremental execution and has escape hatches to integrate with non-incremental code.
Something that looks less like a state machine and more like a React (function) component is what I would like to see. But all experimentation is valuable, and what’s special about the “layers” paradigm is that it enables experimentation. You do not one-shot great tools, they are evolved.






















