3 ms·
Functional languages rest on two main principles: (1) Immutability (2) Transforming inputs to outputs Shared mutable states creates a lot of accidental complex
by vendiddy 7y ago
Functional languages rest on two main principles: (1) Immutability (2) Transforming inputs to outputs
Shared mutable states creates a lot of accidental complexity and makes writing concurrent applications harder. I recommend the talk "The Value of Values" by Rich Hickey for a more in depth analysis.
A traditional while loop like while (x < 5) { ... } involves mutating state, so it's not possible to implement in a purely functional language. In the case of bitwalker's implementation, a value is returned to work around this limitation.