• red_tomato@lemmy.world
    link
    fedilink
    arrow-up
    10
    arrow-down
    1
    ·
    edit-2
    2 days ago

    Outside of the for loop counters i and j, short variable names are awful.

    I’ve started to prefer writing it out as ”index” or ”iteration” even in for loop counters. It’s easier to read, and not much harder to type.

        • silasmariner@programming.dev
          link
          fedilink
          arrow-up
          3
          ·
          edit-2
          1 day ago

          I is a vowel too but you sure can!

          Edit: also I noticed you dropped one ‘y’ but not the others. Is this an accident or some subtlety to do with y’s ‘semi-vowel’ status? To be discussed.

          • lad@programming.dev
            link
            fedilink
            English
            arrow-up
            2
            ·
            23 hours ago

            I had to leave most of first letters, and sometimes if all vowels are removed there’s nothing left

            But yeah, we need a committee and come up with a standard for that

    • FishFace@piefed.social
      link
      fedilink
      English
      arrow-up
      8
      arrow-down
      1
      ·
      2 days ago

      Keeping things that can be on one line to one line is a good reason to use short variable names where it won’t be confusing. Writing “iteration” sounds absolutely perverse!

      The thing is, everyone understands i and j. The reason calling variables hcv or iid is dumb is because noone knows what that means - quite a different situation.

      • red_tomato@lemmy.world
        link
        fedilink
        arrow-up
        5
        ·
        2 days ago

        Writing “iteration” sounds absolutely perverse!

        I like it to make it clear when the for loop is about iterating lists and when it’s not. For example, the iterations in Monte Carlo algorithms doesn’t correspond to items in a list.

    • masterspace@lemmy.ca
      link
      fedilink
      English
      arrow-up
      3
      ·
      2 days ago

      I typically do too, or userIndex or something for nested loops, but I will accept i and j for the first two levels of nesting when reviewing a PR because they’re such a convention. I wouldn’t accept variable names like that anywhere else though and try and avoid them myself.