Comment by jandrewrogers

4 days ago

FORTRAN is also the origin of using 'i', 'j', 'k', etc as loop variables in code, since 'i' was the first variable name that could be used for that purpose. The original language design was constrained by very primitive computers.

i has been the default variable for sum notation in mathematics long before FORTRAN. Here's an example dating from 1838: https://www.numdam.org/item/JMPA_1838_1_3__508_0.pdf

  • It might actually be the other way round: Fortran adopted the convention that i,j,k are integer variables because that was the standard in maths.

  • Where in that doc, sorry? I thought I spotted something then realized it may have been a ‘1’.

    • In equation 9 (and later) for example: Dans ce développement, le terme qui en a i avant lui, a pour expression...

Is that really true, if so, what's your basis? Fourier used i for the same purpose, and it definitely became a pretty standard indexing variable long before the 1950s. Most early code written in FORTRAN was essentially just transcribing formulae and algorithms that already would use such variable names.

The original language design was constrained by primitive thinking and lack of experience. The nature of computers in 1957 had no bearing on such things as variable names starting with I-N being implicitly integers ... that followed existing mathematical practice.

  • "that followed existing mathematical practice". Not what I would call primitive thinking. It set out to handle math quickly and it succeeded. I/O wasn't its strength, and I'm sure the latest versions look like verbose C.

The reason 'i' was the first letter available was because by default identifiers starting with, I think, I-N were integers instead of float.

When I first started, with BASIC, my variable of choice was T simply because it was easy to type NEXT T in the FOR loops (why not R? I dunno...T just stuck).

  • Other way around. I–N were integers rather than float because mathematics convention uses i, j, … as indices and n, m as sizes or counts.