3 ms·
> You also have no chance of accidentally committing a print statement. Debuggers are ephemeral---unless they are "reversible", which is a subject of ongoing r
by lifthrasiir 7y ago
> You also have no chance of accidentally committing a print statement.
Debuggers are ephemeral---unless they are "reversible", which is a subject of ongoing research. You can't replace logging with debuggers, and some print statements used for debugging are in fact better described as post-hoc logging. On the other hands, print statements do change your program and can mask some other problems especially in multi-threaded programs.
> There are literally no drawbacks to switching to a debugger.
Only for properly prepared environments. In some environments enabling a debugger itself can be annoying or even close to impossible (for example, some non-native socket-based debuggers tended to be fragile). I use debuggers when I can, but being able to not rely on debuggers is useful from time to time.
- pjmlp 7y agoSure you can, thanks to OS trace points like ETW.
- lifthrasiir 7y agoI believe you do not always keep ETW or similar instrumentions on, while logging is typically always on.
- pjmlp 7y agoLogging is also not always on, unless one has CPU cycles to burn.
- lifthrasiir 7y agoThen probably I was talking about something else. I meant persistent logging for later inspection, not ephemeral logging for one-off debugging (yes, it is confusing...).
- smt88 7y agoYou seem to have inferred two straw-man arguments from my comment: 1) that people should stop logging, and 2) that debuggers can be used in 100% of cases. > You can't replace logging with debuggers I never suggested this. I only discussed whether to use printing or debuggers for debugging. > Only for properly prepared environments Of course, but these are the vast majority. Most devs are working with Java, Python, C#, TS/JS, Visual Basic, Go, or some combo. All have debuggers.
- lifthrasiir 7y agoWhile I meant not to fully refute but rather to build upon your statements, some clarification seems necessary: > I never suggested this. I only discussed whether to use printing or debuggers for debugging. Yes, but I specifically mentioned some usefulness of printing for debugging ("post-hoc logging"). Printing can be used both for debugging and for logging simultaneously, and many debugging prints can be readily converted to actual logging. As far as I know there are no widespread equivalents in debuggers---but please let me know if any, I'm genuinely curious. > Of course, but these are the vast majority. Most devs are working with Java, Python, C#, TS/JS, Visual Basic, Go, or some combo. All have debuggers. Their quality wildly varies though, and they are especially fragile when multiple languages or environments are in play. In my recent case, Visual Studio 2017 froze when debugging mixed C++ & C# codebase. I tried a lot, but eventually I didn't want to investigate further and decided to use print debugging for the moment. It was finally fixed when I and my team upgraded to VS 2019, I still don't know why it didn't work and it fixed itself.