• GodIsNull@feddit.de
    link
    fedilink
    arrow-up
    0
    ·
    edit-2
    1 year ago

    i for index or iteration. Using j, k, l… in loops signals (imho) that there is most likely an outer loop and the one using j, k, l are nested. x and y of course are carthesian coordinates . n is used as amount of substance in SI-unit-system, m is mass, maybe thats why it is used as amount of items in a set (Menge).

    Programming computers have started to solve mathematical problems and math already used these symbols for centuries(?), so why you should change them? They are well established even in simple school mathematics. And at the end of the day a computer is nothing more than a calculator.

  • youRFate@feddit.de
    link
    fedilink
    arrow-up
    0
    ·
    edit-2
    1 year ago

    Usually variables like that can be avoided with itterators nowadays. If they can’t I like to use idx, if they are nested I name them after what they index, like idx_rows, idx_cols.

  • fubo@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    1 year ago

    Fortran, really.

    In Fortran, variables beginning with the letters i through n have integer type by default, whereas all other letters imply a real-number (floating-point) variable. You can change this by declaring a type, but using i for a real is non-obvious.

    (Hence the old joke, “God is real — unless declared integer.”)

    • Eager Eagle@lemmy.world
      link
      fedilink
      English
      arrow-up
      0
      ·
      edit-2
      1 year ago

      idk, this arbitrary i-n range behaving differently than other variables sounds like a terrible source of weird bugs to me. I don’t think variable names should ever change a program’s behavior.

      edit:

      Many old Fortran 77 programs uses these implicit rules, but you should not! The probability of errors in your program grows dramatically if you do not consistently declare your variables.

      source

      • Successful_Try543@feddit.de
        link
        fedilink
        arrow-up
        0
        ·
        1 year ago

        This comes from early years, when FORTRAN was introduced and the programmers needed to save space in the punch cards. Today, to avoid this possible source of bugs, you usually state “implicit none” in the preamble.

  • juliebean@lemm.ee
    link
    fedilink
    arrow-up
    0
    ·
    1 year ago

    in programming, and in mathematics, it’s always been weird to me that frequently paired variables are basically the most easily confused for one another pairs, especially when written quickly or sloppily.

    • i and j
    • x and y
    • m and n
    • Eager Eagle@lemmy.world
      link
      fedilink
      English
      arrow-up
      0
      ·
      1 year ago

      exactly, this is so annoying. I don’t know by first-hand experience, but I also think p and q are confusing for dyslexic people.

      • juliebean@lemm.ee
        link
        fedilink
        arrow-up
        0
        ·
        1 year ago

        i knew i was forgetting some other common pairings, thank you. p/q and u/v always bugged me too.

        • VisualBuilder4@feddit.de
          link
          fedilink
          arrow-up
          0
          ·
          1 year ago

          u and v were so difficult for me to differentiate in handwriting. My handwriting is not that pretty and the difference between a round bottom and a sharp bottom is not that big when stressed in an exam.