State introduces an abstract notion of time in programs.
In functional programs, there is no notion of time… Functions do not change. In the real world, things are different. There are few real-world entities that have the timeless behaviour of functions. Organisms grows and learn. When the same stimulus is given to an organism at different times, the reaction will usually be different.
How can we model this inside a program? We need to model an entity with a unique identity (its name) whose behaviour changes during the execution of the program. To do this, we add an abstract notion of time to the program. This abstract time is simply a sequence of values in time that has a single name.
We call this sequence a named state.
State machines are a materialization of time.
Josh Beckman
Insight
This widget generates “insights” about a post - you can read about how it works.