Hacker News new | ask | show | jobs
by Cicero22 1680 days ago
> Avoid the debugger.

People who don't use the debugger, do you generally have more/better logging? What other advantages would there be to not using a debugger. Perhaps simpler code, so that you don't need to use a debugger to debug?

3 comments

To motivate why learning how to solve problems without a debugger is a useful skill, there are times when using a debugger is not feasible.

Sometimes you might simply mot have a debugger. I had an old WinCE 6 system whose debugger I never got working. An even older 80186 system with a custom RTOS. I have no idea how you would debug that. (The 286 added some pins for in-circuit emulation, so I’m guessing such a system would be easier to build a debugger for)

Sometimes having a debugger attached slows down the system so much it is no longer functional. Specifically hooking a debugger to HHVM seems to slow down execution by quite a bit.

If you are debugging a real time motion control, you get one shot per move to capture what is going on. This is because your motor control software stops executing while the debugger is pause by the physical motor is still moving. So when you resume execution your physical motor is not where it should be and your controller either tries to compensate or error out.

Sometimes the act of attaching a debugger prevents the problem from occurring. For example it can change the interleaving of multiple threads of execution and cause your race condition to go away. Or on some microcontrollers if your debugger reads a hardware register it can cause the value of the register to change.

Sometimes your debugger can cause the problem to happen more reliably. I had an intermittent corruption in a floating point calculation. Stepping through with the debugger made it 100% reproducible, as the data-corrupting interior handler had plenty of time to run while single-stepping the main thread.

After a while, your code will be easier to reason about, you will learn how to use asserts and proper logs, and you will write much better error messages. Why I need to launch a debugger, when I can detect an error condition with assert and put relevant information into the error message?
I try to avoid the debugger. I know what my code is doing because I have unit tests and yeah I'd like to think simpler code. If my code is doing something unexpected I try to reproduce the issue with more unit tests. Sometimes the debugger is unavoidable, especially if a third party dependency is doing something weird.