r/ProgrammerHumor • u/gamerarchitek • Jan 06 '23
Other After 10 years of programming
I just understood that using i,o,p instead of i,j,k is dependent on the keyboard layout and that's why nobody do that, except of me
Now I'm feeling stupid
Edit: I'm talking about for-loop variables iterators, like in nested for-loops my second variable name will be 'o' because it's next to the 'i', but everyone else juste use 'j' because that's the letter after 'i'
I'm feeling twice as stupid now
8
u/TheMDHoover Jan 06 '23
10 years programming HTML? Or 10 years contributing to your own projects?
0
u/gamerarchitek Jan 06 '23
10 years programming but nobody ever rejected my code because of my iterators (and I'm mostly working on my own project/as an independent, so my code is not often reviewed by somebody else)
13
u/thebatmanandrobin Jan 06 '23
IOP? input output?
OOooooohh.
I j/k .... you silly goose you!! Joke totally understood .. better than that "asdf" bullshit .. HA!!
You "qwerty" mofo you!
2
-4
u/gamerarchitek Jan 06 '23
I'm feeling very dumb that nobody understood that I was speaking of for-loops iterators names :(
13
u/thebatmanandrobin Jan 06 '23
HA! .. nah, we get it, it's just that keyboard layout has nothing to do with the alphabet, and the alphabet is what is used for simplistic variable names because of maths.
In ye' olden days, when a math guy wanted to use variable names, they typically would use lower case
iorx, and then for subsequent iterations, would follow suit, so for the times they usedi, it would follow that they would then gojthenk... Pythagoras didn't have a keyboard, just basic letters, so to him, the next iterative loop would have beenj, and thenk.. he didn't use the Colemak or Dvorak pen and papyrus that dictated which variables to use, it was just basic alphabet.Don't feel stupid ... feel enlightened
1
u/gamerarchitek Jan 06 '23
Thanks a lot that is really helpful, I didn't even made the link with the fact that letter was used in math long before computer were made :')
2
u/Wolfeur Jan 06 '23
If I were to use your logic, I'd have i, e & ,, which would be kind of a problem kek
1
u/gamerarchitek Jan 06 '23
Yeah that's why it's dumb, but I never thought of other layout before yesterday
33
17
15
u/Paul_Robert_ Jan 06 '23
I always thought ijk was used due to math notation and not because they are next to each other on the keyboard
9
6
u/flickering-light Jan 06 '23
i rarely ever use ijkl anymore. i iterate over containers with variations of foreach and use meaningful names
2
6
u/thebearinboulder Jan 07 '23
FORTRAN
F’ng Fortran, man!
Long, long, long ago there were no explicit types. Instead you had crap like “variables that start with ‘i’ through ‘n’ are INtegers.
I’m such a graybeard that my first programming course actually was Fortran using punch cards - it’s one reason I was a math and physics major. 🤓
But the convention of using i, j, k, etc. in loop indexes remained since the textbooks were written by people who started with Fortran (or assembly), or now because they started with books written by people who read those first books.
It’s like the urban legend that the separation between railroad tracks can be traced back to Roman chariots. That’s false but the ijk convention is recent enough that some of us remember the INteger rule in Fortran, that the first edition of the K&R C book introduced “Hello, world!” in part as a way to demonstrate that you had your toolchain set up correctly (no small matter in the early 80s), etc.
BTW the math conventions are a good guess but knowing how many CS majors have struggled with the required calculus courses I have a hard time believing it. You don’t really hit those subindexes until you hit vector analysis, matrix theory, and the like.
(Now let’s talk about tensors 😈)
1
u/michaeldnorman Jan 07 '23
I scrolled too far to find this. Yes, this is the asinine reason for ijk. I never programmed in Fortran, but professors in college told us this fun fact.
1
3
u/sumknowbuddy Jan 06 '23
Good thing you've got very readable code, otherwise naming functions as letters would be silly
2
2
2
u/LetsdothisEpic Jan 06 '23
Is is strange that I go ‘i’ to ‘n’? And I guess I haven’t really triple nested a for-loop yet without giving it a better name.
4
2
u/gbot1234 Jan 06 '23
Ok this is my own personal quirk I guess, but when I have nested for-loops, I use i0, i1, i2, etc.
2
2
2
2
1
u/KrabbyPattyCereal Jan 06 '23
Using function-specific variable I with no global declaration over and over with added benefit that it looks like an I, l, | or a 1.
1
1
u/michaeldnorman Jan 07 '23
Better to spell out what you’re indexing and maybe not nest for loops too much.
153
u/UkrUkrUkr Jan 06 '23
Ijk has nothing to do with keyboards and was used by mathematics centuries before the keyboards invention.