4 ms·
Nice article but there's a lesson here. First I'll come with an old bug of mine (early nineties). The bug was very hard to reproduce because it was very very
by martinced 14y ago
Nice article but there's a lesson here.
First I'll come with an old bug of mine (early nineties). The bug was very hard to reproduce because it was very very occasional (but terrible in consequences). I simply couldn't find it. I knew I was probably smashing some memory somewhere (I was not that experienced in C) but couldn't find where.
So what did I do after weeks of hunting the bug? I moved my design away to an entirely deterministic one and started recording all the inputs the program received and then I could replay them. At one point, logically, the bug happened. And so was it "recorded". Because my program was now deterministic, I could simply feed it the inputs (and the time at which they happened) and, surely enough, the bug was there.
And then finding the cause of the bug was of course trivial.
What's the lesson?
Well, first obviously bugs that you cannot easily reproduce because you cannot "reproduce the state" are typically kinda hard to track down.
The less "state" in your program, the easier it is to reason about your program and the easier it is to reproduce the state.
The lesson?
Functional programming rocks.