Avoid Mutable State
A necessary feature of a purely functional language is that it has no side effects; functions are supposed to return an answer based on arguments, but nothing in the system should be changed by executing a function.
This often strikes programmers new to functional programming paradigms as strange, because to them, the point of a program is to change or “mutate” some state somewhere and record it or show the new state to the user. And this hints at some of the differences in the types of problems pure functional language programmers want to solve compared to “the rest of us.” But there are benefits to avoiding mutable state in any system.
One of the most relevant benefits of having no mutable state in a function is that ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access