The story I heard was that Fortran variable names were limited to a single letter, and each letter had a pre-defined type. The letter i was the first in the group of integers, so when people needed a simple variable to increment in a DO loop (Fortran’s for loop) they used i. The letter i standing for “increment” also probably raised its popularity, along with other things. I have no way to verify this, but it’s a neat story, so I thought I’d share it.
Maybe even more familiar to the casual math-doer, i and j are common/traditional indices for matrices in linear algebra. And also common in sigma notation, which is probably even more closely related to the concept of a loop in code.
What I've seen of mathematicians, they're vehemently opposed to using i as the summation index, because it's too easily confused with the imaginary unit. k, l, m, n are usually used, especially in the context of PDEs where i, j, k can be confused with spatial directions so the first summation index is l. Associated Legendre polynomials are traditionally indexed as P_l^m(cos(theta)), where I presume the letter P stands for "polar" as they arise from the polar component of the Laplace equation.
they're vehemently opposed to using i as the summation index, because it's too easily confused with the imaginary unit.
Mathematician here... No. It's only a problem when there's room for confusion. Sometimes I use z_i to denote a sequence of complex numbers, and I think that's fairly common. It's always clear from context.
People will use pretty much any letter as an index. When I took differential geometry as an undergrad, we had so many indices that we started using a, b, c,..., t, u, v,... as subscripts. We tried to spell out our prof's name in each equation.
This is the actual reason. Especially in the early days coders probably had some mathematical background. If you do, it really does make sense to use i and j as loop or index variables. This is why I use i and j at least.
Early FORTRAN variable names weren't just one letter, but the first letter of the name determined the default type. Variables starting with I through N were integers.
Been retired now for a couple years, but I still write C# code for my hobby. I'm slightly interested in returning to work, but I haven't kept up with the Core stuff, and keep not keeping up, unfortunately.
Not really. My coding buddy and I would stay late at school for 4-5 hours a few times a week, pounding out the paper tape on the teletype machine. It's keyboard required a lot of pressure. No blood those.
We were so into it, we decided to skip college and just get jobs. We had no idea how to get a job, though. We dropped resumes off at a couple places, didn't hear back. So I got a bachelors and went to grad school, neither degree related to programming -- then took a job at a consulting firm where I mentioned I could write FORTRAN and as a result spent my career coding. It was fun!
My Dad was the manager of a data processing center and hired programmers -- and discouraged me as a high school student with the news that there's no money in programming. Kind of like when Ken Olson, head of Digital Equipment Corp, wondered "Why would anyone want a computer in their home?" as PCs were becoming a thing. THAT boat I didn't miss. After coding for DEC machines for a decade, I got started on C++ on Windows 3.1.
By convention, discrete integers are named after their initial, “i” , which also is the first letter of “item”. Further variables are simply named by taking the next one.
I've seen i and ii sometimes, but going full roman numbers is something I've never seen. Could be cool visually and makes the level of recursion more clear, but you have to type more characters.
I’m old enough to have been a FORTRAN teaching assistant in college, and thats what I remember. (But admittedly I my memory is a bit blurry from those days)
View all comments
413
u/tedshif Jun 06 '20
The story I heard was that Fortran variable names were limited to a single letter, and each letter had a pre-defined type. The letter i was the first in the group of integers, so when people needed a simple variable to increment in a DO loop (Fortran’s for loop) they used i. The letter i standing for “increment” also probably raised its popularity, along with other things. I have no way to verify this, but it’s a neat story, so I thought I’d share it.