3 ms·
Whenever I use print for debugging I end up running the code many, many times. Each time I add another print statement. "Here1", "Here2", "Here3 %s %s %s"... I
by jpollock 3y ago
Whenever I use print for debugging I end up running the code many, many times. Each time I add another print statement. "Here1", "Here2", "Here3 %s %s %s"...
If I break out the debugger, I run the code once.
- dev1ycan 3y agoI think it's just that people have anxiety/aren't very used to debuggers so print is less stressful even though in reality it takes 10 times more
- mingus88 3y agoThe very first thing I do when setting up any new dev environment is trying to attach a debugger to my local build It’s setup time that pays dividends for years afterwards. I think many folk don’t bother until they need to fix a bug and at that point you are in a sunk cost situation.
- polonbike 3y agoUnfortunately, not all languages/systems have an efficient and useful debugger. This becomes especially true when multiple stacks are involved. But the print statement remains possible across almost all tools, technologies and systems
- mturmon 3y agoAgree. Another use case for printf debugging is occasional or transient issues where there is a bug, but it only presents in an aggregate of many runs (or a lot of runtime). I debug scientific simulations in this way with printf's, because I need to look across 100 log files to find 2 or 3 instances of a bug. Then I can reproduce it and zoom in on the exact problem with either more logging or a debugger.
- edflsafoiewq 3y agoUnless you decide you needed a breakpoint in the past.
- bogwog 3y ago...and you're not on Linux, because on Linux we have rr! https://rr-project.org/ https://rr-project.org/ (I still use print statements 99.99% of the time though)