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

The only downside to print statements is forgetting to remove them and having some obnoxious message committed.


A useful trick we've had at previous workplaces which solves this (and related accidental-debug-code-checkin) problems is to put a precommit hook that denies a checkin with a certain string in the text (we used "DNCI" for Do Not Check In)

So you get in the habit of annotating test tweaks & debug prints with:

printf("DNCI x is %d\n", x);

I use gdb as well, but sometimes dumping data directly is all you really need.


This is rarely a problem when using tools like darcs, magit, or git-add --patch.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

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

Search: