Bad dev habit: using a bazillion console.log/println like a caveman instead of using a proper debugger.

  • 4
    Here is my 2 cents: use chrome remote debuggin, you can also run js snippets while debugging to see different outputs. It saves tons of time when you are trying to fix bugs that takes too much time to reproduce.

  • 2
    @hack ooOo that's nice, I'll definetely check it out, but the problem is that most of the time I'm too lazy to configure the debugger, so I just use console.log :p

    Ironically enough, I end up taking more time adding and removing log statements than I would if I took 10mins to figure out how to configure the debugger and actually used it.
  • 8
    To be fair, I think knowing how to debug using console logs (in any language) is an extremely valuable skill... Debuggers are fine but there are some things to consider imo:

    1. Putting console logs all around might give you a good idea where you should actually leave console logs for an actual debug mode, so you can ask users for debug logs if something goes wrong

    2. Especially in multithreaded environment (or with a lot of Timeouts) it's sometimes much easier to follow a stream of text logs than the actual madness happening inside the computer

    3. even in single-threaded apps, it's still sometimes nice to let the code run fully and then read the output to get a good understanding of what's happening, even if the logs are literally log("here"), log("here2"), log("here3")

    4. What if you're in a situation without an IDE and internet connection but you still wanna code?! You better know how to use those logs well :P
  • 2
    @neeno that’s me lol
  • 2
    @Hazarth agreed, knowing how to figure out what the code is doing only with logs is a good skill to learn. However, sometimes it's way easier and less time consuming to just use the debugger, so it's also good to know how to use it.
  • 2
    It's a good option if you have nothing but a bare bones editor to your disposal for some fucking reason
  • 1
    @Tonnoman0909 lol at that point you're working like a caveman, not just debugging like one
  • 1
    @neeno that's a good point
  • 5
    I normally don't use debuggers because I can read code, understand what it does, then fix the issue. This helps not only to write fewer bugs in the first place, but also to do code reviews and spot even potential bugs and lurking robustness issues.

    What I find outright ridiculous is the sort of devs who need a debugger in single step mode to figure out what their own fucking code is even doing. Hilarious. Also, it's really no particular skill to set some breakpoints or watchpoints with a mouse click.

    For the exceedingly rare cases where some shit is so obscure that a bug manifests somewhere completely else, I use raw command line GDB because I just can't be bothered to fire up some bloated piece of IDE shit.
Add Comment