O'Reilly logo

Functional Programming: A PragPub Anthology by Michael Swaine

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required