• AMDIsOurLord@lemmy.ml
    link
    fedilink
    arrow-up
    0
    ·
    1 year ago

    The developer must either provide the logging and attach a debugger or go get fucked when a runtime error happens

    • drolex@sopuli.xyz
      link
      fedilink
      arrow-up
      0
      ·
      1 year ago

      You can also debug post-mortem with the minidump or the core dump file with WDT on Windows. Great fun and a good way to brush up on your assembly skills

      • marcos@lemmy.world
        link
        fedilink
        arrow-up
        0
        ·
        1 year ago

        Great fun and a good way to brush up on your assembly skills

        Just load it on the debugger and leave your asm skill gather patina.

    • Faresh@lemmy.ml
      link
      fedilink
      arrow-up
      0
      ·
      edit-2
      1 year ago

      That’s not true though. You can get the backtrace and other useful information from the coredump mentioned by the error message by loading it with gdb. Not as good as attaching it to a living process, since you can’t see step-by-step what happens leading up to the error, but still quite useful.

      • AMDIsOurLord@lemmy.ml
        link
        fedilink
        arrow-up
        0
        ·
        1 year ago

        Well yes, that’s a pretty good way of debugging a third party app but if you are developing something you can have more ease with gdb attached

      • marcos@lemmy.world
        link
        fedilink
        arrow-up
        0
        ·
        1 year ago

        The same applies to using the core dump.

        In fact, the Python one is the lest useful of the trio.

        • xmunk@sh.itjust.works
          link
          fedilink
          arrow-up
          0
          ·
          1 year ago

          When the day comes that you need gdb you will indeed be amazed at how fucking powerful it is. If your server crashes grab that core dump!

    • Aurenkin@sh.itjust.works
      link
      fedilink
      arrow-up
      0
      ·
      1 year ago

      I think it’s pretty useful, be interested to hear your hangups with it though because it’s definitely not perfect.

      If something goes wrong and I have a stack trace, that plus the type of exception will almost always be enough for me to figure out what’s wrong at least as a starting point. I’ve worked mostly with JVM languages in my career though so maybe I just don’t know how bad it actually is.

    • It actually is if you known how to read it. It’s extremely verbose, but you can follow any exception down to the exact line of code (or JNI call, I guess) where the problem occurs. I’ll gladly take the kilobytes

      Unfortunately, Java programmers seem to hate actually handing errors, so you see a lot of try{} catch (Exception e) { throw System.println("something went wrong");} ruining your life, but that’s not the language’s fault.

      • kbal@fedia.io
        link
        fedilink
        arrow-up
        0
        ·
        1 year ago

        Super-advanced java devs like me do it like try{} catch (Exception e) { System.out.println("something went wrong); e.printStackTrace(); }

            • tool@lemmy.world
              link
              fedilink
              English
              arrow-up
              0
              ·
              1 year ago

              On Error Resume Next never before have more terrible words been spoken.

              Every time I’m reading a PowerShell script at work and see -ErrorAction SilentlyContinue I want to scream into a pillow and forcefully revert their commit.

              I’ve actually done it a few times, but I want to do it every time.

      • merc@sh.itjust.works
        link
        fedilink
        arrow-up
        0
        ·
        1 year ago

        but you can follow any exception down to the exact line of code (or JNI call, I guess) where the problem occurs.

        But, it’s not really where the problem occurred. How often do you get a stack trace and the bug fix is at the line referenced by the stack trace? Almost never. It’s more that it takes you down to the exact line of code where the effects of the problem are bad enough to affect the running of the program. But, the actual problem happened earlier, sometimes much earlier.

        For example, NullPointerException isn’t actually the problem, it’s a symptom of the problem. Something didn’t get initialized properly, and nobody noticed for a while, until we tried to use it, and got a null pointer. Sometimes it’s easy to go from the effect (null pointer) to the cause (uninitialized thing). But, other times that “thing” was passed in, so you have to work backwards to try to figure out where that thing comes from, and why it’s in that broken state.

        Sure, it’s better than nothing, but it’s still frustrating.

        • When reproducing a bug? Most of the time. Reasoning back from the variable name and location of a null dereference with a provided call path is much more than you get with tons of languages, especially when calls from frameworks or external libraries enter the mix.

          It won’t tell you exactly what to fix, you’ll need to debug for that (C# does some black magic to allow you to do that, Java doesn’t come close to the capabilities of full fat Visual Studio), but you won’t need to waste any time deciphering where the program crashed.

          Every crash is frustrating, but the stack traces themselves are super useful.

      • lowleveldata@programming.dev
        link
        fedilink
        arrow-up
        0
        ·
        1 year ago

        you can follow any exception down to the exact line of code

        Which is usually not a piece of code written by us and is caused by another piece of code not written by us either

        • MyNameIsRichard@lemmy.ml
          link
          fedilink
          arrow-up
          0
          ·
          edit-2
          1 year ago

          Does your IDE not highlight the lines written by you in a different colour? Of course that doesn’t help when it’s an error in production!

        • I don’t know any programming language where that isn’t the case, though. Unless you’re writing another SerenityOS, you’ll probably use external frameworks and libraries to take care of all the uninteresting stuff.

  • FlatFootFox@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    1 year ago

    My favorite compile error happened while I was taking a Haskell class.

    ghc: panic! (the ‘impossible’ happened)

    The issue is plainly stated, and it provides clear next steps to the developer.

  • heavy@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    0
    ·
    1 year ago

    I know this is supposed to be humorous, but there’s a reason why these languages can, and are doing what they’re doing.

    Core dumps are also worth learning about, they’re really helpful if you understand them.

    • henfredemars@infosec.pub
      link
      fedilink
      English
      arrow-up
      0
      ·
      1 year ago

      Yes. It’s a surprisingly bad debugger the more you think about it. I use it largely in assembly and it loves to spit out random errors about memory it tried to access based on the current register state. The shortcuts are kind of dumb.

      It certainly works but I wouldn’t call it a pleasure to use.

      • xan1242@lemmy.ml
        link
        fedilink
        arrow-up
        0
        ·
        1 year ago

        I honestly vastly prefer using IDA and Windows specific tools (x64dbg) over gdb. IDA can interface with gdb so it can act as a frontend which can be handy for visualization.

      • TunaCowboy@lemmy.world
        link
        fedilink
        arrow-up
        0
        ·
        1 year ago

        I use gdb with great success for x64, rv64, and c:

        info registers rip or just setup tui:

        # ~/.config/gdb/gdbinit:
        tui new-layout default regs 1 {-horizontal src 1 asm 1} 2 status 0 cmd 1
        tui layout default
        tui enable
        
    • OpenStars@startrek.website
      link
      fedilink
      English
      arrow-up
      0
      ·
      1 year ago

      This right here - C++ iirc is used mostly for microprocessor code in an industry setting, where EXTENSIVE testing is done so that bloated code doesn’t need to constantly check for programmer errors every single time, i.e. where execution speed is prioritized over programmer development time. And whenever that is not the case, well, as OP pointed out, other higher-level languages also exist (implication: to choose from).

      • Backslash@feddit.de
        link
        fedilink
        arrow-up
        0
        ·
        1 year ago

        C++ iirc is used mostly for microprocessor code

        lol no, it’s used almost everywhere where performance is important and people want(ed) OOP, from tiny projects to web browsers (Chrome, Firefox) to game engines (Unreal, CryEngine). Many of these are hugely complex and do encounter segfaults on a somewhat frequent basis.

        Saying C++ is mostly used for embedded applications is like saying C# is mostly used for scripting games, i.e. it doesn’t nearly cover all the use cases.

        higher-level languages also exist

        This depends on your definition of “higher-level”, but many people would argue that C++ is on a similar level to Java or C# in terms of abstraction. The latter two do, however, have a garbage collector, which vastly simplifies memory management for the programmer(generally anyway).

        • tool@lemmy.world
          link
          fedilink
          English
          arrow-up
          0
          ·
          1 year ago

          Lots of those in C# now, especially with Unity coming along like it did.

      • scrion@lemmy.world
        link
        fedilink
        arrow-up
        0
        ·
        1 year ago

        I also currently use it for a new project since all needed 3rd party libraries are from a very specific domain and the project has a deadline, so writing and testing wrappers for Rust that would provide me with any meaningful advantages down the road are too costly to budget for before the deadline.

        That could become part of a future refactoring, though.

    • DampCanary@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      1 year ago

      If only I could show segfaul stack tracetrough looped macros.

      It breaks VSCode (it would be hilarious if I wasn’t the author of said macros).

  • Subverb@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    1 year ago

    Nevermind that the C++ program is two orders of magnitude faster when completed.

    I would love to learn and use Rust but I’m a embedded systems guy. Everything of consequence is C and C++.

    • bartvbl@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      1 year ago

      How useful would they be when they rely to such a large extent on various callback functions?