Ramblings of an aging IT geek
← Ramblings of an aging IT geek
personal

the bug i solved twelve miles from my desk

Why staring at a stubborn bug rarely solves it, and how a cold December ride out and back did.

Coffee and books on a desk

I'd been stuck on a bug for most of a day. The kind where the code clearly should work, the test clearly says it doesn't, and the gap between those two facts is so obviously small that you're certain the next ten minutes will crack it. They don't. Neither do the ten after that. By mid-afternoon I'd read the same forty lines so many times they'd stopped meaning anything, which is the real danger sign.

So I gave up and went out on the bike. December, properly cold, the sort of day where you question the decision at the end of the drive but never on the way back. I had no intention of thinking about the bug. That's rather the point.

A cold winter landscape

About twelve miles out, somewhere on a long empty climb with nothing to look at but hedgerow, the answer just arrived. Not the bug I'd been staring at. A different one, upstream, that was quietly handing the broken code the wrong input. I'd been debugging the symptom all day because the symptom was where the error message pointed, and the error message was lying, as they do. The actual fault was two functions earlier and entirely innocent-looking.

I didn't rush home. There wasn't any point, the insight wasn't going anywhere, and the descent was the best part of the ride. When I did sit back down it took about five minutes to confirm and fix.

I've stopped treating this as a curiosity and started treating it as a method. When I'm genuinely stuck, properly wedged rather than just tired, the most productive thing I can do is leave. Not switch to another task at the same desk, which is just stewing with extra steps, but physically go somewhere the problem can't follow and let the back of my head get on with it unsupervised. The conscious, grinding, re-read-it-again approach is good at the first eighty percent and useless at the last twenty. Past that point every extra minute of staring makes things worse, because you stop reading what's there and start reading what you expect to be there, which is precisely how you miss the lying error message in the first place.

There's a discipline to it that took me years to accept, because leaving feels like giving up and giving up feels like losing. It isn't. The work continues; I'm just not in the room for it. The trick is recognising the moment early, before you've burned three more hours proving to yourself that you tried everything, when the honest signal was there at the first hour. I'm still not good at calling it that early. I usually wait until I'm thoroughly sick of the problem, which is later than ideal but at least reliable.

I don't fully understand why it works and I've stopped needing to. The brain does something with a problem when you stop poking it, the body moving seems to help, and the cold December air apparently helps most of all. The bike is, on the balance sheet, one of the better debugging tools I own. It just doesn't fit on the desk.