• magic_lobster_party@kbin.social
    link
    fedilink
    arrow-up
    1
    ·
    5 months ago

    I would swap Python with C++. Constantly dealing with stupid runtime errors that could’ve been easily captured during compile time.

    Did you forget to rename this one use of the variable at the end of the program? Sucks for you, because I won’t tell you about it until after 30 minutes into the execution.

    • Eager Eagle@lemmy.world
      link
      fedilink
      English
      arrow-up
      1
      ·
      edit-2
      5 months ago

      you need a linter, bro

      when integrated into the editor it’ll highlight stupid mistakes as they’re typed

      I recommend Ruff for real time checks, and pylint if you need a comprehensive analysis.

        • Eager Eagle@lemmy.world
          link
          fedilink
          English
          arrow-up
          1
          ·
          edit-2
          5 months ago

          As if that’s a bad thing… it means you’re not locked in with a tool you don’t like and the language itself doesn’t dictate your workflow.

          There’s very little benefit and a lot of potential problems in using a single tool for everything.

      • aidan@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        5 months ago

        Yea and C++ is the same thing, you just need to enable all the warnings on clang-tidy

        • Eager Eagle@lemmy.world
          link
          fedilink
          English
          arrow-up
          1
          ·
          5 months ago

          👆 definitely linting first 👆

          finding errors as you type is even better than finding errors at compile time

        • R0cket_M00se@lemmy.world
          link
          fedilink
          English
          arrow-up
          0
          ·
          5 months ago

          Shouldn’t be forgetting for one off scripts either, if that’s the logic you want to go with.

          The tool exists, either you do it or you don’t and end up getting an error until the interpreter hits that line. It’s just the nature of being compiled at runtime.

          • magic_lobster_party@kbin.social
            link
            fedilink
            arrow-up
            0
            ·
            5 months ago

            “Ohh, I got all these numbers I want to crunch using numpy or pandas and plot it using matplotlib. Hold on, I just need to write unit tests first.”

              • magic_lobster_party@kbin.social
                link
                fedilink
                arrow-up
                1
                ·
                5 months ago

                TDD only works well if the problem is clearly specified before the first line of code has been written, which is rarely the case when I need Python for something.

    • AeroLemming@lemm.ee
      link
      fedilink
      English
      arrow-up
      0
      ·
      5 months ago

      I mean, is C++ any better? Sure, it catches some errors at compile-time, but others can turn into undefined behavior pretty easily.

    • nxdefiant@startrek.website
      link
      fedilink
      arrow-up
      0
      ·
      edit-2
      5 months ago

      You can solve this with git:

      git gud

      Seriously though, writing a monolith of a function and not testing anything until you run it the first time isn’t the way to go. Even with a compiler you’re only going to catch syntactical and type issues. No compiler in the world is going to tell you you forgot to store your data in the correct variable, although it or a a linter may have helped you realize you weren’t using it anywhere else.

      • Johanno@feddit.de
        link
        fedilink
        arrow-up
        1
        ·
        5 months ago

        Python was typeless. And it was common to reuse variables with different types of content.

        So you at some point never knew what actually is within the variable you are using.

        Using typing in python solve 95% of your problems of having runtime errors instead of compile errors