by userbinator · 4y ago · 0 comments
This is a very good point. I have taught beginners before, and saw many of them would somehow open the debugger in their IDE, then start stepping through all their code absentmindedly, as if the mere act of doing so would somehow cause the bug to become apparent. By the time they see something wrong, they've already gone well past the point at which the first error was. I have called this phenomenon "debugger tunnel-vision". It seems like the debugger is more like a ritual to them, some sort of magic that will automatically find bugs quickly and easily, and they get immensely confused when that strategy obviously doesn't work.
I turn them towards using prints, and many times they find the bug even before the next run of the program, while considering where and what to print.
IMHO the "tool fetish" that some programmers have is actually counterproductive.
I have found that reverse debuggers (rr, pernosco) fix the tunnel vision issue by forcing you to identify something wrong ('no, this shouldn't happen') and then letting you work your way up, constantly asking questions ('ok, where is the next thing that doesn't make sense') instead of passively hitting F8.
Basically, debugging is an active process, which requires a proper strategy, and print, code reading, and reverse debuggers all force you to have/design a strategy. Regular forward debugging doesn't in many cases, especially when you are not familiar with the code or the usual strategies you apply don't work in your slightly devious particular case.
Imo you've blamed tool fetish when it's really inexperience that is the problem.
So
> Tools help you be more productive. The keystroke reduction in using debuggers far supercedes print debugging
Sometimes yes, but in general I have seen those tools get into the way. For some reason I rarely need them and juniors often get mislead and don't see the forest for the trees.