News for hackers. Stuff that matters.
Re:Taming names in software development by kitd on Sunday December 11, 2022 @06:56AM (#33942437)
In JavaScript, you’ll often see i, j and subsequent letters as iteration variables. i is not descriptive, and j is somehow even less so.

Using i & j etc for indices dates back to older versions of FORTRAN where the variable type depended on the first character of the name, with i- n reserved for integers.

Quite why the convention has persisted for so long is one of SW Engs little mysteries.

Re:Taming names in software development by furyofantares on Sunday December 11, 2022 @07:13AM (#33942521)
Surely it predates that as well, I assume FORTRAN chose ijklmn as the integers due to i,j,k being used as indices in mathematical convention, (as well as n for sequences and m,n for matrices.)
Re:Taming names in software development by maccard on Sunday December 11, 2022 @08:02AM (#33942796)
> Quite why the convention has persisted for so long is one of SW Engs little mysteries.

I like it - it's a convention that has clear context once it's initially understood. It saves the argmuent of "is it an index, counter, loop iterator, <something else>" - it's the i/j/k'th loop's index.