3 ms·
I read a long time ago, that either Kernighan or Ritchie said they never use a debugger and just sprinkle printf() statements.
by alfiedotwtf 4y ago
I read a long time ago, that either Kernighan or Ritchie said they never use a debugger and just sprinkle printf() statements.
- sfpotter 4y agoConcluding that using printf to debug is superior to using a debugger would be a mistake! I’ve been programming in C for nearly 20 years and primarily used printf for debugging for the first 12-15 years, and have used debuggers more and more. I use Emacs, and its gud mode is so nicely integrated into everything that using gdb is truly much, much faster than the alternative. I don’t use print debugging at all anymore. It takes less time and cognitive overhead to just stop the program on the same line you would have inserted your printf, but you can now inspect the entire program state. Obviously I’m not saying anything revelatory if you use an IDE on a regular basis… I guess this comment is for the folks who eschew IDEs.
- wojciii 4y agoThis works well mostly and I use this. I usually implement a logging system where I can enable/disable individual components but use a debugger to examine functions which are not behaving as intended.. or core dumps. Usually in connection with an unit test that fails or started failing caused by my changes to the codebase that I'm working on. Logging alone is fine, but it can often be difficult not to drown in information. I do embedded programming in C mostly.