logoalt Hacker News

jandrewrogers • today at 4:00 PM • 5 replies • view on HN

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.


Replies

throw-the-towel • today at 4:25 PM

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

➕ show 1 reply
tyromaniac • today at 4:10 PM

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.

jibalt • today at 4:48 PM

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.

➕ show 1 reply
whartung • today at 4:09 PM

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).

➕ show 1 reply
392 • today at 6:32 PM

origins are very relative, it seems to have [started a bit before](https://stats.stackexchange.com/questions/176965/what-do-i-a...) :D