Hacker News new | ask | show | jobs
by hirundo 2606 days ago
> Kernighan once wrote that the most effective debugging tool is still careful thought, coupled with judiciously placed print statements.

Of course the first tool is careful thought. But when forced to fall back to print or log statements it feels like a handicap.

If I have to use a print statement it means I'm not sure what's going on so I'm not sure what, exactly, to print. By breaking on that code I don't have to know exactly because I can execute arbitrary code in that scope. What takes multiple iterations with print is often just one with break.

I can compare directly, because on a production-only bug I'm forced to use log debug statements. And usually in that case I have the same code open locally in a debugger. The difference is night versus day.

Maybe it's like a chess master who really doesn't need the board. For the kid in Searching for Bobby Fischer, it may really be a distraction. But I notice that grandmasters use a chess board in serious competition. And as a programmer I'm no grandmaster, and I play this weird game better with the board in front of me.