5 ms·
I like debuggers and use them when I can, but folks who say you should only use debuggers tend to not realize: * Not all languages have good debuggers. * It's
by piinbinary 2y ago
I like debuggers and use them when I can, but folks who say you should only use debuggers tend to not realize:
* Not all languages have good debuggers.
* It's not always possible to connect a debugger in the environment where the code runs.
* Builds don't always include debug symbols, and this can be very high-friction to change.
* Compilers sometimes optimize out the variable I'm interested in, making it impossible to see in a debugger. (Haskell is particularly bad about this)
* As another commenter mentioned, the delay introduced by a debugger can change the behavior in a way that prevents the bug. (E.g. a connection times out)
* In interpreted languages, debuggers can make the code painfully slow to run (think multiple minutes before the first breakpoint is hit).
One technique that is easier to do in printf debugging is comparing two implementations. If you have (or create) one known-good implementation and have a buggy implementation, you can change the code to run both implementations and print when there's a difference in the result (possibly with some logic to determine if results are equivalent, e.g. if the resulting lists are the same up to ordering).