15
The whole "use a debugger" advice isn't always the answer
I was stuck on a loop issue in my apartment in Columbus three weeks ago, and every forum told me to step through it with a debugger. Problem was, the bug only showed up after 200 iterations and the debugger kept crashing because of memory issues. Instead, I just added a bunch of print statements at each step and watched the console output scroll by for 15 minutes. Found it was a variable resetting itself because of a typo in a conditional. Has anyone else had a time where old school logging beat using a fancy tool?
3 comments
Log in to join the discussion
Log In3 Comments
mason.drew10d ago
Man, that brings back memories of my college days when I had a bug that only showed up after like 500 iterations and the debugger would just eat all my RAM and freeze. Ended up just flooding the console with print statements and squinting at the terminal for half an hour. Turns out I had a variable name that was one letter off from a global one in a different module. Classic case of my own dumb typing being the real enemy.
4
jamesc7910d ago
Printf debugging always saves my bacon too.
3
blairm7710d ago
Is it just me or does that kind of thing happen way more often in real life than we admit? Like you'll be looking for your keys for ten minutes and they're right in your hand, or you'll keep typing the same wrong password over and over before realizing caps lock is on. It's that same brain glitch where you see what you expect to see instead of what's actually there. I know for me, half the mistakes I make at work or around the house come down to me mentally auto-completing stuff and missing the one small detail that throws everything off. Maybe it's just a reminder that our brains are lazy and take shortcuts even when we think we're being careful. The dumb typing is always the real enemy, in coding and in life I swear.
3