Better living through immutability or What have functional programmers ever done for us?

For more than thirty years, alongside conventional language development, there’s been a small but thriving culture of functional languages.  These are not like the languages we all know and love.  Their most obvious property is that they contain no variables at all; instead, they describe truths about the problem to be solved[1].

As anyone with even a passing familiarity with functional programming knows (and I accept that passing familiarity usually comes only after three to five years), things in a functional language don’t do anything (the way procedures execute or variables change in conventional languages); instead they are something, and what they are never changes.  A term may describe a function which defines a list of primes, or it may describe what it means to be an expression, or what-have-you.  But whatever it is, it describes it once and for all time – the function is the list of primes, it’s not a sequence of operations to compute the list.

Proponents of functional languages claim that by talking exclusively in terms of values, you get shorter, simpler, and more reliable programs.  If things are things, rather than do things, they reason, then if they ever work, they’ll always work.  If nothing ever changes, where can a bug hide?

Continue reading