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

the bug i fixed by leaving my desk

Spending a Saturday morning stuck on a bug, going for a cold ride instead, and solving it without a keyboard in sight.

Coffee and books

I lost most of Saturday morning to a bug that wasn't hard. I just couldn't see it. You know the state: you've read the same forty lines so many times your eyes slide over them, and every theory you form is the one you've already disproved, and you keep typing the same print statement in slightly different places hoping the computer will change its mind. It will not.

By eleven I'd written nothing useful for two hours, drunk too much coffee, and started to take the whole thing personally, which is the surest sign it's time to stop. So I put the laptop to sleep, got the bike out, and went for a ride. It was February and properly cold, the kind of grey that doesn't so much rain as hang in the air and gradually soak you anyway. Not pleasant, exactly. But moving.

A grey winter landscape

The thing about cycling, for me, is that it occupies just enough of my brain. I have to watch the road and the potholes and the one driver who's decided cyclists are optional, but the rest of my head is free, and crucially it's free in a way that staring at a screen never allows. The problem stops being a wall of text and becomes a shape you can turn over.

About twenty minutes out, on a long flat stretch where I wasn't thinking about the bug at all, the answer just arrived. The off-by-one wasn't in the loop I'd been staring at. It was in the function that built the input to the loop, two files away, which I'd never once looked at because I "knew" it was correct. I'd been debugging the symptom and trusting the cause. Of course.

I didn't turn round. I finished the ride, came home cold and pleased with myself, made a fresh coffee, and fixed it in about ninety seconds. One character. The walk-away wasn't procrastination dressed up as wellness. It was the actual debugging step, the one where you stop forcing the wrong model and let your head reset enough to find the right one.

I'm not going to pretend every ride ends with a fix. Most of them just end with cold hands. But the pattern is real enough that I've stopped treating "go outside" as giving up. When I've read the same code four times and learned nothing, the most productive thing I can do is leave the desk. The bug will still be there. So, usually, will the answer.