• Clinicallydepressedpoochie@lemmy.world
    link
    fedilink
    arrow-up
    4
    ·
    edit-2
    1 hour ago

    The older I get the more impatient I get with stupid tasks that take longer then they should. I simplify my life by focusing on the task ahead of me. Knowing these small tasks compound into the final goal.

    So when I am looking through 17 different folders for a file I can’t remember what I saved it as and I’m sorting by date and opening things frantically…

    ‘it’s been 20 fucking minutes, should I just take the rest of the day to organize my shit? But if I get this fucking thing done I can setup a meeting on this today and fit it in this week before Juan goes on vacation and I have to wait two weeks to place an order that will take 6 months to deliver.’

    ‘Fuuuuuuuuu where the fuck is this file, I’ll just start from scratch and I’ll be done by 2pm just in time for it to go on the calender so everyone can seee. Or maybe i just look another 15 minutes wheeerreeeee the fuckkkk did I save this?!?!’

    'Bullshit bullshit bullshit!"

    Google: how to find file.

    Google: how to find file just working on.

    Google: how to find excel file by date, most recent.

    Google: file not in recent, why come?

    Google: did I dream a this nightmare wake me, wake me, wake me.’

  • bricked@discuss.tchncs.de
    link
    fedilink
    English
    arrow-up
    13
    ·
    16 hours 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
      4
      ·
      15 hours 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
      30
      ·
      1 day 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
          9
          ·
          23 hours 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
            3
            ·
            15 hours ago

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

            • UndercoverUlrikHD@programming.dev
              link
              fedilink
              arrow-up
              2
              arrow-down
              1
              ·
              15 hours ago

              OP suggested that linters for python won’t catch attribute errors, which they 100% will if you use type hints, as you should.

              What happens at runtime is really relevant in this case.

                • UndercoverUlrikHD@programming.dev
                  link
                  fedilink
                  arrow-up
                  1
                  ·
                  edit-2
                  25 minutes ago

                  I don’t want to get into an Internet argument over pedantry. Linter is often used as a catch-all term for static analysis tools.

                  Wikipedia defines it as

                  Lint is the computer science term for a static code analysis tool used to flag programming errors, bugs, stylistic errors and suspicious constructs.

                  Catching type errors and attribute errors would fit under this description, if you use a different, more precise definition at your workplace, cool, then we just have different definitions for it. The point is that your IDE should automatically detect the errors regardless of what you call it.

          • Starbuncle@lemmy.ca
            link
            fedilink
            English
            arrow-up
            4
            ·
            23 hours 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
          9
          arrow-down
          2
          ·
          1 day 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
            link
            fedilink
            arrow-up
            14
            ·
            1 day 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
            6
            ·
            1 day ago

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

        • ripcord@lemmy.world
          link
          fedilink
          arrow-up
          2
          arrow-down
          2
          ·
          1 day ago

          Not with an example that simple and poor, no.

          If you have done the minimum and at least set a type hint, or if your ide is smart enough to check what calls the function and what it passes, then it’ll be flagged.

          • calcopiritus@lemmy.world
            link
            fedilink
            arrow-up
            3
            ·
            edit-2
            2 hours ago

            This is literally a getter function. How is a getter awful code? It’s the simplest function there is. The only function simpler than that is returning the input itself.

            • BrianTheeBiscuiteer@lemmy.world
              link
              fedilink
              arrow-up
              1
              arrow-down
              1
              ·
              6 hours ago

              How does “foo” mean “get”? Half the battle of writing correct code is writing code that’s easy to interpret. Do you always look at the guts of every function you’re about to use?

          • Ephera
            link
            fedilink
            arrow-up
            4
            ·
            1 day ago

            How would you make it non-awful, without specifying static types?

            I guess, a unit test would catch it, but needing 100% test coverage to catch typos isn’t exactly great…

            • BrianTheeBiscuiteer@lemmy.world
              link
              fedilink
              arrow-up
              1
              arrow-down
              1
              ·
              edit-2
              1 day ago

              What’s the purpose of foo? Why an ambiguous single character variable? What if the property was there but the value was null? Why not use (assuming JS) optional chaining?

              I’d approach it more like this:

              function getWhatevrProp(userData) (
                const default = { whatevr: "n/a" };
              
                return { ...default, ...userData }.whatevr;
              }
              

              Sorry, read too fast the first time. It’s more likely Python. I also don’t know Python well enough to give recommendations on that.

              • FizzyOrange@programming.dev
                link
                fedilink
                arrow-up
                3
                ·
                1 day ago

                It’s an example to demonstrate that linters cannot reliably detect variable name typos - you need static types. None of the stuff you mentioned is relevant.

                The typo in your example is also undetectable by linters. I think you’re missing the point.

  • Feathercrown@lemmy.world
    link
    fedilink
    English
    arrow-up
    6
    ·
    1 day ago

    I spent like 3 hours yesterday deduplicating two functions that were hundreds of lines long and nearly identical. I should probably learn how to use that git command that can diff two files on disk. Luckily I actually enjoy cleaning up code sometimes.

    • orbitz@lemmy.ca
      link
      fedilink
      arrow-up
      4
      ·
      23 hours ago

      Dunno what OS’s it supports besides Windows but I use Kdiff for random comparisons regularly, I think it works pretty well untill you get to much larger files (20+ MB slows down a lot). The huge file wasn’t code but needed to check output changes for those curious.

      I constantly check git comparison with previous versions to see what changed to break things in a build though. Didn’t know there was a way to diff any files in git,should probably just learn to use that one.

      • Ephera
        link
        fedilink
        arrow-up
        3
        ·
        20 hours ago

        Git uses the diff binary under the hood (unless you configure it to use something else).
        You can invoke that directly with diff file_a.txt file_b.txt.

    • hayes_@sh.itjust.works
      link
      fedilink
      arrow-up
      2
      ·
      20 hours ago

      git diff —no-index before.json after.json > showmethegoods.diff

      You don’t have to save it to a file but I often do.

    • pivot_root@lemmy.world
      link
      fedilink
      arrow-up
      11
      ·
      1 day ago

      If you’re using a decent development system, you’ll have an executable called diff installed already :)

    • egrets@lemmy.world
      link
      fedilink
      arrow-up
      4
      arrow-down
      1
      ·
      1 day ago

      VS Code’s diff tools are killer. Comparison is smarter than most, and you can edit either file as you go.

      • wizardbeard@lemmy.dbzer0.com
        link
        fedilink
        English
        arrow-up
        4
        ·
        1 day ago

        And if you want to avoid the Microsoft stank, there’s VS Codium that has been de-Microsoft’d, like Chrome vs. Chromium.