by pron · 12y ago · 0 comments
The solution, then, is not doing away with shared mutable state, as that's downright impossible, but with providing transactional semantics for that state. Once shared state has clear transactional semantics, the pure-functional nature of the programming language becomes secondary.
Let's imagine a programming language with perfect STM (i.e. an STM implementation that executes the most efficient code possible in every transaction). That language would have none of the problems described in the article, even if it were completely imperative. Hence, the problem is managing shared mutable state, and not existence of side-effects in general.
Pure functional programming could have been one solution to the problem, if only for the fact that it's not even a solution at all: Haskell programs still need a database. But the article assumes no other possible solutions, which is wrong. It focuses on one particular solution (which isn't even really a solution), rather than exploring many approaches. It is simply begging the question.
EDIT: I do agree that some partially-functional approaches are inherently dangerous, but I do not agree with the conclusion that the answer is going pure functional.
[1]: Except maybe for compilers, which is probably the most common complex software built in Haskell.
There's an important distinction between essential side-effects and inessential side-effects.
Some data you have to store in a database is an essential side effect.
Modifying iterator or flag (e.g. bool isOpen) etc. is a non-essential side effect.
Transactional semantics are probably part of the story for the former, but the author was talking about the latter.
I'm not saying that Clojure is the silver bullet, it's just that the article's conclusion does in no way follow from the premise.
What do I mean by isolation of mutation? As stated above, all applications end up needing global shared mutable state (usually it lives in databases, but doesn't have to). So Rich Hickey created mechanisms to do such things safely and concisely.