3 ms·
Because writing functional code forces you to define your program in mathematical terms and this improves your ability to reason about your program. Imperative
by rekrsiv 4y ago
Because writing functional code forces you to define your program in mathematical terms and this improves your ability to reason about your program.
Imperative code is very convenient when you're describing processes that access a lot of shared global state at the lowest level, but it becomes difficult to keep track of everything when you have a lot, and math doesn't know how to handle that much complexity.
But math can help with simpler things, like unary functions that aren't allowed side effects. And if you opt-in to only using unary functions without side-effects, you get to use most of category theory for free.
Simplicity is the ultimate sophistication, and functional programming requires simplicity.