|
|
|
|
|
by aeonik
1453 days ago
|
|
The biggest benefit I see is lack of side-effects. With a functional program you can be sure that your can safely call any function without having to worry about the current state of your app. A proper functional program can start to do very cool things safely: like hot reloading of code. When I'm debugging a Clojurescript app I can have a live running game, and update the physics without even reloading the page. It's all live. A proper functional program really looks like a series of mappings from a collection of data sources to a collection of data sinks. The keyword for this is referential transparency: https://www.braveclojure.com/functional-programming/ There are other benefits like composability, designing your programs this way will give you access to algorithms that works otherwise not work with your code. The simplest example is Map, Filter, and Reduce. These functions are by their very nature parallel because a compiler knows that there are no intermediate steps, unlike a for loop. |
|
But I was minimizing state long before that because state makes any program much harder to understand.
Confessions of a Used Programming Language Salesman: Getting the Masses Hooked on Haskell http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.72....