Hacker News new | ask | show | jobs
by andix 1906 days ago
Because you shouldn’t have to change code, just to debug it.

It’s okay though to add verbose logging as a feature.

But just adding some print statements to debug code and remove them afterwards, is dangerous (you release sth different than you debugged).

3 comments

As opposed to software breakpoints which change your compiled binary at runtime in order to debug it. Even if you're using hardware breakpoints you're still changing what the CPU is doing and can easily make multi-threading bugs disappear.
I do it in a different branch & discard it afterwards. Having said that, I never meant print() should be used in place of a proper debugger. All I am saying is they both can complement each other and each one has its place & value. As for me, I find it quicker to add a few print statements and get a rough idea before firing up a debugger(if required). May be others are more proficient in using debuggers. But print() works for me.
############################# What? #########################