• Haus@kbin.social
    link
    fedilink
    arrow-up
    27
    ·
    edit-2
    10 months ago

    Bad variable names and then awful “temporary” log lines… I feel attacked this morning. ;)

    • LasagnaCat@lemmy.world
      link
      fedilink
      arrow-up
      8
      arrow-down
      2
      ·
      edit-2
      10 months ago

      It blows my mind how often i see people using temp logs for debugging when breakpoints exist

      • deegeese
        link
        fedilink
        arrow-up
        16
        arrow-down
        1
        ·
        10 months ago

        When the issue is only seen after hours of runtime, logging is more practical.

        • Chreutz@lemmy.world
          link
          fedilink
          arrow-up
          7
          ·
          10 months ago

          I recently had an issue that happens on one out of between ten thousand and a hundred thousand interactions between two embedded processors. Thank god for logging!

          • o11c@programming.dev
            link
            fedilink
            arrow-up
            6
            ·
            10 months ago

            Even logging can sometimes be enough to hide the heisgenbug.

            Logging to a file descriptor can sometimes be avoided by logging to memory (which for crash-safety includes the possibility of an mmap’ed file, since the kernel will just take care of them as long as the whole system doesn’t go down). But logging from every thread to a single section of memory can also be problematic (even without mutexes, atomics can be expensive and certainly have side-effects) - sometimes you need a separate per-thread log, and combine in the log-reader tool.

          • marcos@lemmy.world
            link
            fedilink
            arrow-up
            3
            ·
            10 months ago

            Well, conditional breakpoints exist.

            But use whatever is easiest. People trying to micromanage how others use computers are the worst. And on the most popular languages by job count, your debuggers isn’t all that more powerful than a well-constructed log anyway. (Hell, the people insisting that others adopt better tools should start with the language.)

      • XTornado@lemmy.ml
        link
        fedilink
        arrow-up
        2
        ·
        10 months ago

        Idk… I had problems in the past with weird bugs where the breakpoints do not match the right line although using sourcemaps and all that so sometimes you end up doing stuff like this. Or if you want to know how many times something executes without well having to “continue” on each breakpoint or similar.

  • sebi@lemmy.world
    link
    fedilink
    arrow-up
    21
    ·
    10 months ago

    This is a professional debug techique, what are you talking about? But I rather use ‘Hii’ with various (but not ascending) amounts of i’s.

    • andrew@lemmy.stuart.fun
      link
      fedilink
      English
      arrow-up
      6
      ·
      edit-2
      10 months ago

      Sometimes I use various swears. Depends on how long I’ve had to debug. Also depends on whose work I’m debugging and whether they’re in earshot. Usually it’s just my own sketchy code though.

    • dbilitated@aussie.zone
      link
      fedilink
      arrow-up
      2
      ·
      10 months ago

      I’ve used a regex to add a console log to the top of every method with the method name before.

      the things you do when you’re desperate.

  • elxeno@lemm.ee
    link
    fedilink
    arrow-up
    4
    ·
    10 months ago
    var num =0
    ...
    console.log("Here " + num++)
    ...
    console.log("Here " + num++)