🐿️
6

I was at a library coding workshop in Phoenix and a kid showed me a better way to debug.

I was stuck on a loop that wouldn't end for like 45 minutes. This 12-year-old next to me leaned over and said, 'Why don't you just print the counter each time?' I felt like an idiot. I was trying to trace it in my head instead of just making the program tell me what was happening. Now I use print statements for everything. What's your go-to trick when your code just won't work?
2 comments

Log in to join the discussion

Log In
2 Comments
eric_johnson
Oh man, that's a classic (and honestly, print statements are still the best debugger). But careful with using them for everything though. For bigger projects, you can end up with a mess of prints you have to clean up. I usually lean on the actual debugger in my editor now. You can set a breakpoint and walk through the code line by line, seeing every variable. It feels like magic the first time you use it.
3
wyattbennett
Ever try debugging async code with a debugger? I always hit weird timing issues where the breakpoints mess up the flow. Print statements feel like the only thing that actually shows what's happening in real time.
8