4 ms·
It's great that more people are exposed to the functional programming style. Kudos to OP for trying something new. It bugs me whenever FP people talk about st
by ww520 16y ago
It's great that more people are exposed to the functional programming style. Kudos to OP for trying something new.
It bugs me whenever FP people talk about state being bad as if it should be avoided at all cost. State is bad if its scope is not carefully managed. Global state is generally bad because its scope allows the whole program to modify it, making it difficult to follow its validity. Local state maintained as a local variable in a function is perfectly fine. Its scope is small and its changes can be tracked easily. Pure functional code actually also implicitly maintain state in their parameters and return values, and the passing of the return values as parameters to next function.
- silentbicycle 16y agoIt's ultimately about making code easier to reason about. Immutability (at least as a default) makes the dataflow between independent portions of your program clearer, since every value is determined by where it came from, not where it came from and everything that could have potentially touched it along the way.
- silentbicycle 16y agoOh: Easier for the compiler to reason about, too. Not just the programmers.