• henfredemars@infosec.pub
    cake
    link
    fedilink
    English
    arrow-up
    116
    ·
    2 months ago

    I worked with a developer who insisted on using the shortest names possible. God I hated debugging his code.

    I’m talking variable names like AAxynj. Everything looking like matrix math.

    • redcalcium@lemmy.institute
      link
      fedilink
      arrow-up
      63
      ·
      edit-2
      2 months ago

      Ah, must’ve been a fortran developer. I swear they have this ability to make the shortest yet the least memorable variable names. E.g. was the variable called APFLWS or APFLWD? Impossible to remember without going back and forth to recheck the definition. Autocomplete won’t help you because both variables exist.

        • T (they/she)@beehaw.org
          link
          fedilink
          arrow-up
          7
          ·
          edit-2
          2 months ago

          I’d say because fortran is often used for calculations such as numerical analysis where you have x, y and z for example.

          I have written fortran code in the past and it was mainly for that.

      • mkwt@lemmy.world
        link
        fedilink
        arrow-up
        20
        ·
        2 months ago

        And you can write more than six characters, but only the first six are recognized. So APFLWSAC and APFLWSAF are really the same variable.

        And without namespaces, company policy reserves the first two characters for module prefix and Hungarian notation.

  • Malix@sopuli.xyz
    link
    fedilink
    arrow-up
    52
    ·
    2 months ago

    installing operating system: 15 minutes, give or take.

    give a name to the computer: 45 minutes

    • SturgiesYrFase@lemmy.ml
      link
      fedilink
      arrow-up
      16
      arrow-down
      1
      ·
      2 months ago

      I’ve got that shit on lockdown man.
      I name all my devices “Fuck0ff” followed by a 3 letter descriptor of what it is. E.g. - my windows install is Fuck0ffDTW for Desktop Windows, my Garuda install is Fuck0ffDTG for Desktop Garuda(it’s a flavour of Arch, btw)

      • OfficerBribe@lemm.ee
        link
        fedilink
        arrow-up
        8
        ·
        edit-2
        2 months ago

        What if you would have 2 devices of same type with same OS or just with OS that starts with same letter? Will you use numbers, if yes, how much leading zeroes if any you will use? If you don’t use numbers, will you add a room name? But what if there are 2 devices with same OS in the same room?

        • SturgiesYrFase@lemmy.ml
          link
          fedilink
          arrow-up
          6
          ·
          2 months ago

          Luckily I’m not responsible for naming my wife’s devices, otherwise the whole scheme would be up shit creak. As it stands I have a dual-boot desktop, a daily laptop, a surface pro4, and an old laptop running Ubuntu server for various self hosted stuff. I’ve managed to just use 3 letters, I assume as I amass more tech I’ll need to start adding numbers, if I have to label for rooms I’ll have more than a data hording problem.

    • LostXOR@fedia.io
      link
      fedilink
      arrow-up
      34
      ·
      2 months ago

      Who needs private variables when you can generate cryptographically secure variable names? Much better security.

    • rufus@discuss.tchncs.de
      cake
      link
      fedilink
      arrow-up
      11
      ·
      2 months ago

      Make it 63 (31?) to align with what C99 can distinguish.

      Also: I really like unicode in identifiers. So if at all possible don’t just have a random string of letters and numbers, make sure to include greek letters and all the funny emojis. (I just forgot which languages and compilers etc allow that.)

  • steventhedev@lemmy.world
    link
    fedilink
    arrow-up
    34
    ·
    2 months ago

    Older C compilers would truncate a variable name if it was too long, so VeryLongGlobalConstantInsideALibraryInSeconds might accidentally collide with VeryLongGlobalConstantInsideALibraryInMinutes.

    Legend says that they used to do it after a single letter with Dennis declaring “26 variables ought to be enough for anyone”.

    • olutukko@lemmy.world
      link
      fedilink
      arrow-up
      8
      ·
      2 months ago

      I had this problem in my job as a drafter. I was wondering why the hell Tekla would complain about the same object name already being in use despite everything having its own name. took me way too long to realize there wad some stupidly max name length and the program did nothing to alarm the user about trying to put too long name. it just cut the overflow away.

  • DarkSurferZA@lemmy.world
    link
    fedilink
    arrow-up
    28
    ·
    2 months ago

    Gotten even easier after X became a registered trademark. Now the only choice we have left is i. Or ii if you need more variables

  • lars@lemmy.sdf.org
    link
    fedilink
    arrow-up
    27
    ·
    2 months ago

    An important professor constantly and frustratingly said

    we can call this variable whatever we want, so we’ll call it Fred

    Made me panic and irate and focus on the wrong part of the problem. Every. Single. Time.

  • FrostyCaveman@lemm.ee
    link
    fedilink
    arrow-up
    27
    arrow-down
    1
    ·
    2 months ago

    Single character variable names are my pet peeve. I even name iterator variables a real word instead of “i” now… (although writing the OG low level for loops is kinda rare for me now)

    Naming things “x”… shudder. Well, the entire world is getting to see how that idea transpires hahah

    • Mikelius@lemmy.ml
      link
      fedilink
      arrow-up
      21
      arrow-down
      1
      ·
      2 months ago

      I hate short variable names in general too, but am okay with them for iterators where i and j represent only indices, and when x/y/z represent coordinates (like a for loop going over x coordinates). In most cases I actually prefer this since it keeps me from having to think about whether I’m looking at an integer iterator or object/dictionary iterator loop, as long as the loop remains short. When it gets to be ridiculous in size, even i and j are annoying. Any other short names are a no go for me though. And my god, the abbreviations… Those are the worst.

      • FrostyCaveman@lemm.ee
        link
        fedilink
        arrow-up
        7
        ·
        2 months ago

        That’s very reasonable, I can get behind that. (my stance is a partly irrational overreaction and I’m totally aware of it lol)

        Abbreviations are definitely annoying. My least favourite thing to do with them is “Hungarian notation”. It’s like… in a statically typed context it’s useless, and in a dynamically typed context it’s like… kind of a sign you need to refactor

        • Cethin@lemmy.zip
          link
          fedilink
          English
          arrow-up
          3
          ·
          2 months ago

          Hungarian notation makes sense in a dynamically typed usage (which I despise, but this essentially makes them notationally typed at least) or where you’re editor/IDE is so simple it can’t give you more information, which I can’t see ever being the case in the modern day.

        • Redkey@programming.dev
          link
          fedilink
          arrow-up
          1
          ·
          2 months ago

          Most people use the term “Hungarian Notation” to mean only adding an indicator of type to a variable or function name. While this is one of the ways in which it has been used (and actually made sense in certain old environments, although those days are long, long behind us now), it’s not the only way that it can be used.

          We can use the same concept (prepending or appending an indicator from a standard selection) to denote other, more useful categories that the environment won’t keep straight for us, or won’t warn us about in easy-to-understand ways. In my own projects I usually append a single letter to the ends of my variable names to indicate scope, which helps me stay more modular, and also allows me to choose sensible variable names without fear of clashing with something else I’ve forgotten about.

    • Cethin@lemmy.zip
      link
      fedilink
      English
      arrow-up
      9
      ·
      2 months ago

      X, y, and z should only be used when working with things with dimensions larger than 1. Indexing into a 2D array, x and y are great uses. I’m also totally fine with i and j for indexer/iterator when appropriate, but I hate when people try to make short variable names for no good reason. We have auto-complete just about everywhere now. Make the names descriptive. There’s literally no reason not to.

    • nicky7@lemmy.ml
      link
      fedilink
      arrow-up
      3
      ·
      2 months ago

      Same, except for list comprehension in python, I prefer sinlge character var names there.

  • ZILtoid1991@lemmy.world
    link
    fedilink
    arrow-up
    26
    arrow-down
    2
    ·
    2 months ago

    Then you realize your code is undebuggable because half the functions and variables have single-letter names or called foo, bar, baz, etc.

    • AnarchistArtificer@slrpnk.net
      link
      fedilink
      English
      arrow-up
      5
      ·
      2 months ago

      I was learning python as a wee scientist in training, and my variables were beyond dreadful. I tried naming a list “list” and the interpreter told me I couldn’t, so I opted for “listy”. When I needed to name a new list but listy was taken, I’d often resort to “listyy”.

      Scientists who work with computers without having much (if any) targeted training on how to code can write the most horrendous programs.

  • JATtho@sopuli.xyz
    link
    fedilink
    arrow-up
    20
    ·
    2 months ago

    name your function as malloc() and see to world burn and generate bugs at factorial rate.