4 ms·
There are tradeoffs to writing functional code in langauges designed primarily for imperatively. Another comment mentioned efficiency. Another is that in a pur
by sullyj3 5y ago
There are tradeoffs to writing functional code in langauges designed primarily for imperatively. Another comment mentioned efficiency.
Another is that in a pure language, you can look at a function and know for a fact that nothing you're seeing can ever be mutated. This eliminates a massive source of cognitive load when trying to read and understand code, as well as eliminating all sorts of bugs related to the program being in the wrong state. If you're trying to write functional code in a language not designed for it, you're missing out on those benefits.
Now, it's absolutely the case that the tradeoff may be worth making depending on the person and circumstance. But it does exist.
- Ginden 5y ago> Another is that in a pure language, you can look at a function and know for a fact that nothing you're seeing can ever be mutated. This eliminates a massive source of cognitive load when trying to read and understand code, as well as eliminating all sorts of bugs related to the program being in the wrong state. If you're trying to write functional code in a language not designed for it, you're missing out on those benefits. When you write functional code in imperative languages, these constraints aren't enforced by language, but they should be enforced by convention and code review.