• Cowabunghole@lemmy.ml
    link
    fedilink
    arrow-up
    15
    ·
    1 year ago

    It’s my understanding that i,j are conventionally used in mathematics which carried over into programming, but specifically it comes from Fortran in which all integer variables start with “I” through “N” based on said mathematical convention

    • LuckyFeathers@lemmy.world
      link
      fedilink
      arrow-up
      6
      ·
      1 year ago

      Yep, this is the answer. In Fortran, all variables are assumed to be floats, unless the variable starts with I, J, K, L, M or N. I’m sure they had a good reason, but it sounds so bizarre today!

    • galilette@mander.xyz
      link
      fedilink
      arrow-up
      1
      ·
      edit-2
      1 year ago

      In fact this goes all the way back to Hamilton when he invented quaternion, in which i,j,k are used as basis vectors (which are generalizations of the imaginary i). Later Gibbs dropped the scalar component and gave us the modern vector.