• steventhedev@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    5 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
      0
      ·
      5 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.

  • henfredemars@infosec.pub
    link
    fedilink
    English
    arrow-up
    0
    ·
    5 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.

    • ray@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      0
      ·
      5 months ago

      At a previous job I had to work with an old database where all the tables and columns had 6-character names

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

        I don’t understand why people think that it’s acceptable.

        As developers, we’ve had it drummed into us from day one that variable names are important and shouldn’t be one or two letters.

        Yet developers deliberately alias an easy to read table name such as “customer” into “c” because that’s the first letter of the table. I’m sure that it’s more work to do that with auto completion meaning that you don’t even need to type out “customer”.

        • xmunk@sh.itjust.works
          link
          fedilink
          arrow-up
          0
          ·
          5 months ago

          Especially when you also have company and county tables. It forces people to look up what the c is aliased to before beginning to comprehend what you’re doing.

    • redcalcium@lemmy.institute
      link
      fedilink
      arrow-up
      0
      ·
      edit-2
      5 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.

      • mkwt@lemmy.world
        link
        fedilink
        arrow-up
        0
        ·
        5 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.

        • T (they/she)@beehaw.org
          link
          fedilink
          arrow-up
          0
          ·
          edit-2
          5 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.

    • rufus@discuss.tchncs.de
      link
      fedilink
      arrow-up
      0
      ·
      5 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.)

    • LostXOR@fedia.io
      link
      fedilink
      arrow-up
      0
      ·
      5 months ago

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

  • JATtho@sopuli.xyz
    link
    fedilink
    arrow-up
    0
    ·
    5 months ago

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

    • outer_spec@lemmy.blahaj.zone
      link
      fedilink
      arrow-up
      0
      ·
      5 months ago

      floats, doubles, etc are decimallikes. object-oriented programming languages are c++likes. a string that is just the word “false” is a boollike. any language easier to learn than c++ is a pythonlike. any language harder to learn than c++ is a asmlike. don’t like it? then you’re a naglike. you don’t want to be known as a naglike, do you?

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

      Or Fortran variables that collide with Fortran built-in functions.

      Keep in mind that array subscript and function call are both () in Fortran.

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

      Variable names should be “self defining” meaning you should be able to understand what its doing from the name. The name also shouldn’t be too long. Combining those together makes it difficult to come up with an “elegant” name

        • Strawberry@lemmy.blahaj.zone
          link
          fedilink
          arrow-up
          0
          ·
          5 months ago

          The most atrocious variable names I ever encountered in code were as a research assistant for a math professor doing game theory simulations. Literally unreadable unless you had a copy of his paper on the subject to refer to

    • KillingTimeItself@lemmy.dbzer0.com
      link
      fedilink
      English
      arrow-up
      0
      ·
      5 months ago

      in the linux community it’s really common to have applications like MPD, music player daemon, or MPC, music player client, and ncmpc, ncurses music player client, and ncmpcpp the aforementioned one with ++ tacked onto the end.

      Cmus, which from what i can recall is literally “c music player”

      etc…

      • CanadaPlus@lemmy.sdf.org
        link
        fedilink
        arrow-up
        0
        ·
        edit-2
        5 months ago

        So don’t use it in non-KRY-definite AA situations, or you could get erroneous results. QQX is fine though, as long as you have non-vanishing ABCD. /s

        I wonder, if Lean proofs become the new peer review like I’ve heard suggested, if mathematics might break from this, and look more compsci-ish in the future. That way non-specialists could get up to speed quickly.

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

      Ha

      You should hear of the method of pretending you’re at breakfast or some other anthropomorphized situation, where you name things as butter and cheese, knife and bread, tea and teapot

      Then there’s Hungarian notation which is actually used seriously. But I can’t give an entertaining example only s boring and probably inaccurate one.