Things you can do with a debugger but not with print debugging

https://news.ycombinator.com/rss Hits: 5
Summary

People do or do not use debuggers for a variety of reasons. For one thing, they are hard to setup in many codebases. Second, you can’t use them when your application is running on remote environments (such as kuberenetes). So, anecdotally, I have seen way more people using Print/log.Debug compared to a debugger.Which is a shame, because while debug logging is convenient at times, debuggers can do some things which you can’t easily simulate via debug logging.Debuggers let you See all the way up the call stackIn most debuggers you can see all the callers and inspect the state there. So if you don’t know how we got to some stage, you can select the parent frame in the debugger menu and check the variables, or evaluate an expression there.Debuggers can evaluate expressions dynamicallyMost debuggers for high-level languages let you evaluate expressions involving function calls and even modify the state of the running program.This doubles as an REPL with access to all your program state.Debuggers can catch exceptions at the sourceAll debuggers have exception breakpoints which stop at the point where exception is thrown. This is super handy to inspect the exact state and figure out why exception happened. In almost all debuggers, you can also limit this functionality to uncaught exceptions only.You can alter the course of execution without modifying codeLet’s say I am debugging a network issue, and I need to point a URL to another test endpoint and see if the issue still persists. I can stop just before the network call is made, evaluate an expression which assigns the new URL to the variable, and let the code run. This is better than making code changes, because there’s no accidental risk of committing code changes.Using a debug configuration standardizes the project setupIf your team is using VSCode or IntelliJ IDEs, it’s possible to check in debug configuration files so that everyone can have a standardized local development flow. These config files can specify .env fil...

First seen: 2025-09-10 03:06

Last seen: 2025-09-10 07:07