• solomonschuler@lemmy.zip
    link
    fedilink
    arrow-up
    1
    ·
    2 小时前

    Madness. When I started using gdb in C it was lifesaver to find any runtime errors in my code. Coming from what is the shit of C compilation and runtime errors it saved what would effectively be hours of inserting printf statements to find the error.

    It depends how well a language specifies where the runtime error is occuring. I just get “segmentation fault (core dumped)” as my runtime error which could mean any for loop or iterattive sequence in my program.

  • 2deck@lemmy.world
    link
    fedilink
    arrow-up
    36
    ·
    28 天前

    To me logging combined with a quick compilation has a good flow to it. Causes you to consider what you want to see and doesn’t change the workflow if multiple stacks are involved.

  • vala@lemmy.dbzer0.com
    link
    fedilink
    arrow-up
    16
    ·
    27 天前

    As someone who knows how to use a debugger, I can say for sure that log debugging is fine and often my first approach. If you have a good mental model of the code and the issue, it’s usually just 1-2 logs to solve the problem.

  • NotSteve_@piefed.ca
    link
    fedilink
    English
    arrow-up
    13
    arrow-down
    2
    ·
    28 天前

    It drives me crazy that half my coworkers do this, including a senior dev. I’ll be on a call trying to help debug something and it makes it so difficult not being able to set a breakpoint

    • andyburke@fedia.io
      link
      fedilink
      arrow-up
      33
      ·
      28 天前

      I console.dir and debugger; and breakpoint all day. You are allowed to mix your strategies.

        • Omgpwnies@lemmy.world
          link
          fedilink
          English
          arrow-up
          3
          ·
          27 天前

          and the one that keeps getting slept on for some reason, watch breakpoints - stop when foo is changed. Great for figuring out what is screwing with your data when foo mysteriously changes

    • RheumatoidArthritis@mander.xyz
      link
      fedilink
      arrow-up
      7
      ·
      27 天前

      I used to do debuggers until I started doing embedded and dipped my feet in multithreading (2 different projects). After many hours lost because the debugger straight lied to me about which line of code has been executed, a colleague suggested that I just do a printf like a filthy beginner. And 🤩it worked🤩 and I never went back to the unreliable world of debuggers. Even though now I’m mostly working with single-threaded python scripts.

    • Quantenteilchen@discuss.tchncs.de
      link
      fedilink
      arrow-up
      5
      arrow-down
      1
      ·
      27 天前

      There are literally university courses which confidently state “Console logging is far more used and better so we won’t talk about a debugger here”!

      Like sure, it’s very likely to be used far more, but that doesn’t mean you shouldn’t at least offer some courses or modules about proper use of a debugger…

    • darvit@lemmy.darvit.nl
      link
      fedilink
      arrow-up
      2
      ·
      26 天前

      Using -F with tail is even better than -f because it handles files getting truncated or getting created.

  • DrDystopia@lemy.lol
    link
    fedilink
    arrow-up
    6
    arrow-down
    1
    ·
    28 天前

    It’s like the real life kraken, I’ve never seen it but the name causes dread.

    • kubica@fedia.io
      link
      fedilink
      arrow-up
      21
      ·
      28 天前

      This is what peak performance looks like:

      console.log("before dothething");
      let r = dothething();
      console.log("after dothething");
      console.log(r);
      
      • darvit@lemmy.darvit.nl
        link
        fedilink
        arrow-up
        2
        ·
        26 天前

        Be careful, the actual logging can happen at a later time, and because the log function may take a reference to the value, if you modify r it may show the modified version of r in the logging instead of the original r.

  • madcaesar@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    27 天前

    Honestly I use debugger when I have to go deep into some library’s bullshit code. My stuff should be stable clean and understandable enough to quickly see what’s happening with console log.

    If I were to find myself needing debugger all the time with breakpoints and all this shit, it means shits has gone sideways and we need to back up and re-evaluate the code.