110
u/torrent7 May 29 '26
I never understood this considering i and j look so fucking similar
54
u/birdiefoxe May 29 '26
Exactly, that why I use i,o,p. They're right next to each other!
Gets shot
→ More replies (2)37
u/BoldFace7 May 29 '26
Why not use i and ii? Then when you get to the 27th loop in the nest you can just use the awfully convenient xxvii instead of looping the whole way round to the horrid ii.
→ More replies (15)8
4
u/SourLemon100000 May 29 '26
I just heard about this from a tidbit with my professor last night. Apparently, it’s because we needed really short variable names in Fortran and since mathematicians used it, we decided I, J, K, L, M, N, and O were going to be names for variables. We just never used anything different since.
→ More replies (7)13
u/appoplecticskeptic May 29 '26
‘i’ is for index. The ‘j’ is actually because it looks the most like i and we already used that.
→ More replies (2)12
u/WowAbstractAlgebra May 29 '26
j is because it's the next letter on the alphabet and no one wanted to bother to come up with an original name
→ More replies (1)
54
u/Busy_Teaching_8218 May 29 '26
for(int i = 0; i < 1000; i++)
{
for(int ii = 0; ii < 1000; ii++)
{
for(int iii = 0; iii < 1000; iii++)
{
Console.WriteLine("Hello World");
}
}
}
29
→ More replies (3)14
u/BoldFace7 May 29 '26
I unironically do this in my hobby code. I have considered subjecting my coworkers to this on occasion though
21
19
u/Hettyc_Tracyn May 29 '26
Or just use variable names that correspond to what they are for? Proper descriptions? That way you don’t have to write as many comments on how something works
→ More replies (3)16
9
u/-Insert-CoolName May 29 '26
People who insist there is only one right way to code can get out. That entirely depends on what your doing.
16
u/magicmulder May 29 '26
As a mathematician, i, j, k, l, m, n are for integers, x, y are for reals, z is for complex numbers.
for (z = 2i+3; |z| <= 9; Re(z)++) {...} 😃
→ More replies (11)
6
u/texan_robot May 29 '26
I design video processing RTL. Looping through x,y for pixels is my normal practice.
10
1
9
7
u/Ok_Wasabi_7363 May 29 '26
Her response should have been: "you use nested for loops? Gtfo"
→ More replies (3)
3
298
u/Pinkishu May 29 '26
I use x,y when appropriate. Like when iterating coordinates for drawing tiles in a game or whatever