Hacker News new | ask | show | jobs
by pavel_lishin 5570 days ago
> As I had virtually no understanding of the TCP code, I liberally sprinkled it with printf()s

And people say it's a stupid way to debug!

1 comments

What people say that?
Pick any "how do you debug?" submission anywhere, and you'll see a lot of people claiming that using printf, etc, is retarded in the age of good debuggers.

Maybe they're just a noisy minority.

Using printf to debug when you could use a good debugger is...well, I wouldn't say stupid, just highly unproductive.

The problem is there are a lot of problems that aren't debugger friendly, especially if you are new to a particular domain. The kernel, timing-related problems, remote systems, production systems (you have intelligent logging, right?), etc., all have extremely valid reasons for using printf debugging.

One thing I am missing or haven't found in some of the debuggers I have used (mostly Java) is the feature to just print out the code execution and return values for a certain part of or the whole code.

Those prints or printfs are great to get a quick overview of what's going on, if you ask me... instead of stepping through the whole thing.

printf debugging is too simple and intuitive to justify an entire blog post. ;)