← Back to context

Comment by not_kurt_godel

22 days ago

I would estimate print debugging is usually twice the work for 30% of the effectiveness of step debugging. It's the screwdriver to step debugging's drill. Fundamental and absolutely necessary sometimes but not the first tool you should be reaching for unless there's a specific reason.

The specific reason I reach for print debugging first is it works literally everywhere across all technology stacks. I regularly work with different projects written in different languages. Printing works across all of them and the logs are easy to aggregate across different parts of the stack (microservices or other service composition patterns) giving you a broader range of data than you typically get from a step debugger. I've personally found that step debuggers are more likely to create Heisenbugs. Especially in multi-threaded applications or dealing with race conditions.

  • Step debuggers don't "create Heisenbugs", you're just much more likely to notice race conditions while step debugging than print debugging. If anything, print debugging creates more bugs because you're altering the code you're trying to test by definition.

    • Step debuggers can 100% cause or hide race conditions that are exposed via other mechanisms. Especially in multi-threaded apps as I stated. If you've never encountered it, I'd suggest you've never debugged really nasty race conditions or serious bugs.