Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

"Print statements are a valid way to debug code."

In 30+ years of programming, vast majority of bugs I've fixed were diagnosed with a few strategically placed print statements.

"I just print values. When I’m developing a program I do tremendous amount of printing. And by the time I take out, or comment out the prints it really is pretty solid. I rarely have to go back." — Ken Thompson in the book Coders at Work by Peter Seibel



I call this the 'printf' school of debugging.

It works a lot of the time (but not always, not great for debugging locks on stdout, for example). If you only have time to learn one debugging technique, this is the one to learn.


Print statements can generally be thought of as unit tests that require 1 line of boostrapping code.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: