3 ms·
The idea behind FP is to minimize or eliminate implicit state change. This has several advantages. The first is that it eliminates errors caused by unexpected
by weavejester 18y ago
The idea behind FP is to minimize or eliminate implicit state change.
This has several advantages. The first is that it eliminates errors caused by unexpected state change. This is a larger class of errors than you might expect.
The second advantage is that FP applications are easier to unit test. When given a certain argument, FP functions always return the same value, so if f(1) is 2 in your tests, you can be guarenteed it'll be 2 in your application, too. FP generally more predictable.
The final advantage I can think of is concurrency. Concurrency in imperative languages is made harder because a data structure referenced by one thread can be mutated by another. In FP, data structures are immutable, so this problem doesn't occur.