When you do the same thing again and again, and expect a different result, that’s insanity.
When you do the same thing again and again, and get a different result, that’s stateful programming.
Stateful programming will teach you to expect different results when doing the same thing repeatedly.
It is impossible to write code which runs without state.
How’s your job working out for you?
Haskell users would argue that you can write code without state.
How do you run it without state, though?
Yet it is possible to write code functional style.
I blogged it here: http://liquiddevelopment.blogspot.com/2005/12/functional-style.html
–Chiaroscuro
As a filter. A function transforms input to output and it’s behaviour is defined purely by it’s code and it’s inputs and outputs.
I thought the joke was funnier when I told it at XTC. Maybe I had drunk too much London Pride.
it’s [sic] behaviour is defined purely by it’s code and it’s inputs and outputs
…and the state of the machine on which it’s running…
I agree that a function can be written to have no state of its own, but I have yet to hear of code which doesn’t occasionally fall over due to some unforseen state of the configuration required to run it.
Even something as simple as “hello world” can stop working if, for example, you happen one day to be running something else that messes up your Ruby config.
Or maybe run out of memory. Or file handles. That was a really nasty one.