A blog by Gary Bernhardt, Creator & Destroyer of Software

Mutable State Is Manual Memory Management

07 Feb 2007

The Haskell Sequence linked to my post on C# (although they obviously don't share my opinions on it). I'd never read that site before, and I came across this "quote of the week" while glancing over it:

"Mutable state is actually another form of manual memory management: every time you over-write a value you are making a decision that the old value is now garbage, regardless of what other part of the program might have been using it."

(Paul Johnson via The Haskell Sequence)

My first thought upon reading this was "why the hell didn't I think of that?" It's obvious in retrospect, and is a wonderfully concise explanation of why side effects are a bad idea. I always try to limit my use of side effects, but I never had a simple way to explain to myself (or others) why that's a good thing. Thanks, Paul.