3 ms·
"In addition, debugging with print requires more understanding, so it's more likely to be correct than debugging with a debugger." I don't believe this is true
by vilya 16y ago
"In addition, debugging with print requires more understanding, so it's more likely to be correct than debugging with a debugger."
I don't believe this is true. I suspect the way most people use print statements for debugging goes something like: "I think the problem is somewhere in this function, let's stick a print statement here. Oops, that doesn't seem to be it, let's try one here. Oops, that's not it either, let's try printing out a different variable." and so on.
That's remarkably similar to using a debugger only a lot less efficient, because you have to go back through the whole edit-compile-run cycle each time (or maybe edit-deploy-run if you're working on a web app using a scripting language).
- anamax 16y ago> I don't believe this is true. I suspect the way most people use print statements for debugging goes something like: "I think the problem is somewhere in this function, let's stick a print statement here. Oops, that doesn't seem to be it, let's try one here. Oops, that's not it either, let's try printing out a different variable." and so on. What is the basis for your suspicion? I ask because the folks who I see using print as their first-choice for debugging don't work that way. The overhead associated with changes (as opposed to restarting) gives them the opportunity to think (or grab a new cup of tea). That said, that "poke around randomly" approach does seem to be "not rare" for folks who are "debugger first", as you yourself say. To be fair, the folks I know who are most effective with a debugger also put in some time on understanding before they fire it up.