• ZILtoid1991@lemmy.world
    link
    fedilink
    arrow-up
    6
    ·
    2 days ago

    If you thought misspelling a variable was bad, then get ready for misreading documentation of OS API, then not realize why your implementation doesn’t work for a quite a long time.

  • Backlog3231@reddthat.com
    link
    fedilink
    English
    arrow-up
    6
    ·
    2 days ago

    Programming has its highs and lows. Yesterday I spent four hours trying to write a script that honestly probably won’t even be useful to anyone.

    Today I felt like a god because I built a recursive query to pull some ridiculously obscure data from our database.

    Tomorrow I’ll probably delete a table in prod or something.

    You win some, you lose some!

  • bricked@discuss.tchncs.de
    link
    fedilink
    English
    arrow-up
    14
    ·
    3 days ago

    This literally happened to me yesterday, but with filenames. I was failing to configure a program until an hour later I found out that I mispelled the config file as colors.ini instead of color.ini.

    • Kissaki@programming.dev
      link
      fedilink
      English
      arrow-up
      6
      ·
      3 days ago

      I like that even here on Lemmy, with inline code format, colors.ini is not being colored but color.ini is. Great symbolism for your issue.

    • blaue_Fledermaus@mstdn.io
      link
      fedilink
      arrow-up
      22
      ·
      3 days ago

      Static types are great, but not exactly what would have helped here, any decent language or at least a linter should catch the use of a not declared identifier.

        • UndercoverUlrikHD@programming.dev
          link
          fedilink
          arrow-up
          11
          ·
          3 days ago
          class MyClass:
              def __init__(self, x: int):
                  self.whatever: int = x
          
          def foo(x: MyClass) -> int:
              return x.whatevr
          

          Any decent IDE would give you an error for unresolved attribute. Likewise it would warn you of type error if the type of x.whatever didn’t match the return type of foo()

          • FizzyOrange@programming.dev
            link
            fedilink
            arrow-up
            4
            ·
            3 days ago

            Yes because you used static type annotations. This thread was about code that doesn’t use static types (or static type annotations/hints).

            • Eiri@lemmy.ca
              link
              fedilink
              arrow-up
              1
              ·
              2 days ago

              Nope, don’t need to. WebStorm can even detect nonexistent attributes for objects whose format the back-end decides, and tbh I’m not sure what sort of sorcery it uses.

              • FizzyOrange@programming.dev
                link
                fedilink
                arrow-up
                1
                ·
                2 days ago

                Yeah IntelliJ does amazingly without type annotations but even it can’t do everything. E.g. if you’re using libraries without type annotations, or if you don’t call functions with every possible type (is your testing that good? No.)

                Static types have other benefits anyway so you should use them even if everyone in your team uses IntelliJ.

                • Eiri@lemmy.ca
                  link
                  fedilink
                  arrow-up
                  1
                  ·
                  2 days ago

                  Yeah, our company has been meaning to transition to them for a while. I started saying Jsdoc comments but people complained about the pollution. Then I said fine, we’ll do TypeScript one day instead.

                  That one day has yet to come. I don’t actually get to decide much at this company, after all. Aah, technical debt.

          • Starbuncle@lemmy.ca
            link
            fedilink
            English
            arrow-up
            6
            ·
            3 days ago

            You’re both right. It’s possible to write code that gets linted well in Python, yes, but you’re often not working with just your code. If a library doesn’t use typing properly, not a lot to be done without a ton more effort.

        • Strykker@programming.dev
          link
          fedilink
          arrow-up
          8
          arrow-down
          2
          ·
          3 days ago

          It’s python, just use type hinting already and your linter will catch that.

          Also some winters can look at the use of food and see the type being passed in.

          • Ephera@lemmy.ml
            link
            fedilink
            arrow-up
            11
            ·
            3 days ago

            Autocorrect got you pretty bad, there.

            I was very confused, why we’re suddenly talking about rationing food during winter. 🙃

          • FizzyOrange@programming.dev
            link
            fedilink
            arrow-up
            5
            ·
            3 days ago

            Yes you can use static type hinting and the static type checker (Mypy or Pyright) will catch that. Linters (Pylint) won’t.

  • grudan@programming.dev
    link
    fedilink
    arrow-up
    2
    ·
    2 days ago

    I spent such a long time the other day trying to figure out why I couldn’t access an application I wrote and served on a home server from my reverse proxy. Next day I take a look at the DNS record I setup again, CNAMEd to the host server instead of the reverse proxy server. Felt dumb.