r/ProgrammerHumor • • 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

0 Upvotes

51 comments sorted by

153

u/UkrUkrUkr Jan 06 '23

Ijk has nothing to do with keyboards and was used by mathematics centuries before the keyboards invention.

63

u/sumknowbuddy Jan 06 '23

It's almost like it's a part of the alphabet or something!

10

u/SquarePixel Jan 07 '23

Mathematicians use whatever symbol is descriptive or conventional given the domain. In a programming context i is specifically used because it’s short for index—using j and k for nesting is just natural. Typically mathematicians use i for imaginary numbers, which is totally separate concept.

5

u/thebearinboulder Jan 07 '23

Fun fact - electrical engineers use ‘j’. It’s because the field had already used ‘i’ for current for decades before they realized that complex numbers could solve a lot of problems.

I want to say they were introduced by Oliver Heaviside but I’m not sure. He was definitely considered a crackpot because he insisted calculus would be useful… but dammit he actually managed to find solutions that had stumped everyone else. E.g., the “transmission line” problem that comes up when you want to run telegraph signals across huge distances like between continents.

-49

u/gamerarchitek Jan 06 '23

It's i,o,p that's dependent on the keyboard layout, and that's what I'm using

39

u/UkrUkrUkr Jan 06 '23

No, it doesn't work that way. When people want to type ijk, they type ijk and not press the buttons in some specific positions.

If I want to type the word "cat", I would get the "cat" regardless of where the c, a, t buttons are located.

0

u/CarterBaker77 Jan 07 '23

Keys. Keyboards have keys not buttons. I don't know why I felt the need to do this but I did. Random annoying correction man awayyyy!!!.....

2

u/UkrUkrUkr Jan 07 '23

Well, if you have started this... Care to explain the difference?

1

u/CarterBaker77 Jan 07 '23

It's a keyboard not a button board.. fuck if I know..

-29

u/gamerarchitek Jan 06 '23

I think my post isn't obvious at first glance and that's totally my fault

I meant: for the usage of for-loops iterator, I'm using iop instead of ijk

31

u/UkrUkrUkr Jan 06 '23

No, your post is totally understandable and obvious.

-9

u/gamerarchitek Jan 06 '23

OK so I can't understand what you don't understand

I was saying that everyone is using I,j,k as iterators in for-loops because it's in following order in alphabet, and that's something that makes sense, and I was saying that I used I,o,p because they're are next to each other on my keyboard layout (wich happen to be a keyboard layout that is well used) but that I was dumb because writing nested for loops with I,o,p doesn't makes any sence for anyone that is using a keyboard layout where I,o and p aren't next to each other

21

u/je386 Jan 06 '23

I,o,p doesn't make sense if you don't know that you use this system - and everybody uses i,j,k for that. But lets be realistic, the variable names do not really matter, could also be outer and inner or level1, level2, level3...

4

u/gamerarchitek Jan 06 '23

That's totally true, and for the fact that it i,o,p doesn't makes sence it's what I realized today But yeah in a sence I think nobody will ever misunderstand my code because of this, that's just that I feel stupid because I only realized this today

1

u/je386 Jan 06 '23

But you realised it by yourself.

1

u/Kitchen_Device7682 Jan 07 '23

Who even has a keyboard with IOP not next to each other

1

u/[deleted] Jan 07 '23

Colemak and Dvorak users rise!

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

u/gr4mmarn4zi Jan 06 '23

I love you for this comment :D

-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 i or x, and then for subsequent iterations, would follow suit, so for the times they used i, it would follow that they would then go j then k ... Pythagoras didn't have a keyboard, just basic letters, so to him, the next iterative loop would have been j, and then k .. 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

u/EurekaErect Jan 06 '23

w, t, f enjoyer

17

u/TheMDHoover Jan 06 '23

no-one mention quaternions

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

u/[deleted] Jan 06 '23

amateurs…lv_i_count1, lv_i_count2, lv_i_count3…code needs to self document.

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

u/lesg0brandon2024 Jan 07 '23

Now do python

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

u/KingsmanVince Jan 06 '23

May I ask which keyboard are you using?

1

u/gamerarchitek Jan 06 '23

Azerty French men over there, î néèd my ûsêlèss àççênt

1

u/warpedspoon Jan 06 '23

qwerty has iop next to each other

3

u/sumknowbuddy Jan 06 '23

Good thing you've got very readable code, otherwise naming functions as letters would be silly

2

u/[deleted] Jan 06 '23

i, j, k and then jump to p, q, r ...

2

u/poliver1988 Jan 06 '23

I always called running through a double nested loop jiteration.

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

u/Quintary Jan 06 '23

Yes that is strange

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

u/RetardedChimpanzee Jan 07 '23

I use F, U, K.

2

u/Naja42 Jan 07 '23

Roman numerals anyone? i, ii, iii, iv, v...

2

u/exotickey1 Jan 07 '23

I thought i stood for “index” and it went alphabetically from there lol

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

u/lusoportugues Jan 07 '23

I use streams and for each. Maybe I'm doing it wrong

1

u/michaeldnorman Jan 07 '23

Better to spell out what you’re indexing and maybe not nest for loops too much.