r/ProgrammerHumor • • Jun 06 '20

It's the law!

Post image
38k Upvotes

1.1k comments sorted by

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.

0

u/[deleted] Jun 06 '20

[deleted] — view deleted comment

120

u/MattTheGr8 Jun 06 '20

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.

19

u/[deleted] Jun 06 '20

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.

11

u/DrSeafood Jun 06 '20

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.

→ More replies (6)

10

u/Jeromibear Jun 06 '20

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.

→ More replies (1)
→ More replies (1)

95

u/Sjsamdrake Jun 06 '20

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.

51

u/TrumpLyftAlles Jun 06 '20

This is the correct answer.

Source: FORTRAN was my first programming language, 1969

15

u/sup3r_hero Jun 06 '20

You’ve been a programmer for over 50 years?

6

u/TrumpLyftAlles Jun 06 '20

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.

→ More replies (1)

8

u/rubeljan Jun 06 '20

Did you code until your fingers bled?

4

u/TrumpLyftAlles Jun 06 '20 edited Jun 06 '20

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.

Did you code until your fingers bled?

That phrase is kind of familiar. Is it a lyric?

→ More replies (2)

8

u/AshTheGoblin Jun 06 '20

Who is this FOR TRAN?

5

u/howtopayherefor Jun 06 '20

A hacker who leaked nudes of celebrities

→ More replies (1)
→ More replies (8)

35

u/radome9 Jun 06 '20

Fortran variable names were limited to a single letter,

How our species ever made it down from the trees is beyond me.

0

u/[deleted] Jun 06 '20

[deleted] — view deleted comment

6

u/MrDilbert Jun 06 '20

Those who make it to the bottom shake the tree to see who else is worthy.

→ More replies (1)

18

u/[deleted] Jun 06 '20 edited Jun 06 '20

Has more to do with algebra though.

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.

15

u/[deleted] Jun 06 '20

I kind of like the idea of using i, ii, iii, iv, v, vi... but I feel moving from convention in that manner would annoy my colleagues.

11

u/kloga12 Jun 06 '20

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.

→ More replies (1)

4

u/SpaceMathStuff Jun 06 '20

I love the many different takes on what word "i" is the first letter of! Personally I always saw it as standing for "iteration"

3

u/cec772 Jun 06 '20

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)

→ More replies (19)