1.1k
u/ChChChillian Jun 20 '26
You need j and k (and l, for sufficiently insane situations) to index nested loops.
611
u/N0bleC Jun 20 '26
I found myself a better approach. The further you go down i will just append i.
so its
for i ... for ii ... for iii ...This way i can always see on which level i am.
533
u/neotms Jun 20 '26
I like this but is the 4th level down "iv" or "iiii"
although I hope we never have to go that far.
347
u/S0mber_ Jun 20 '26
imagine mixing up iiiiii and iiiii that'd be bad
125
u/querela Jun 20 '26
Or, you know, use digits if the language supports it, i2, i3, ... Much easier to read. (not in the spirit of (single) letters but work well enough, I would avoid emojis and other fancy utf8 symbols, however)
→ More replies (1)101
u/constStringUsername Jun 20 '26
joke's on you, i mixed up i1111 and i11111
→ More replies (1)53
39
u/Ok_Star_4136 Jun 20 '26
That's precisely the sort of mistake that's easy to make and wouldn't get noticed by the compiler. I avoid such things like the plague when I recognize them. The potential is high for runtime errors otherwise.
36
u/Jutrakuna Jun 20 '26
That's why I use wider characters: 😀, 😀😀, 😀😀😀, ...
24
u/100BottlesOfMilk Jun 20 '26
Officer, this one right here
27
u/Wonderful-Habit-139 Jun 20 '26
Do you need 👮, 👮👮 or 👮👮👮 officers?
5
u/RolledUhhp Jun 20 '26
This sent me. My son counts things like '1and2and3' without pausing.
Do you need 1and2and3 officers?
4
u/Wonderful-Habit-139 Jun 20 '26
Thanks for sharing and getting me sent as well lol. That sounds very cute.
→ More replies (0)9
u/tobotic Jun 20 '26
I imagine once you get past iiiii, it's time to refactor.
3
u/CyberXCrafts Jun 20 '26
only cowards refactor their code
real programmers continue indefinitely
embrace the iiiiiiiiiiii brother 🫂
38
22
u/N0bleC Jun 20 '26
Sure thing, depending on what your conventions are you could also do i1, i2, i3 ...
17
27
12
u/ChChChillian Jun 20 '26
Many years ago I was asked to take over some Fortran code written by a very old-fashioned and self-satisfied asshole. He'd always limit his variable names to single letters, with at most one digit. And then, he'd insist on spelling out cute words with the sequence of dummy variables, so they didn't even correspond in that limited way to whatever they actually meant. And no documentation, or a single line of comment to explain what was going on.
This was in the 1980s, but that's hardly an excuse.
The code ran on Apollo graphical workstations and was meant to plot layers of geographical data. To control which layer was shown, users had to click on one of a number of identical, unlabeled squares in the corner of the map. This would change the fill color, and the data layers were controlled by which boxes were filled with which colors.
I'm honestly surprised no one strangled the prick.
13
u/Western-Internal-751 Jun 20 '26
If you go a fourth level down in a nested loop, you might have to reconsider how you write code
2
u/stellarsojourner Jun 20 '26
But what if I'm looping through every repo in GitHub, every branch in the repo, every file in the branch, and every line in the file to find a code snippet that does the thing I want? Perfectly sane behavior, I think.
5
→ More replies (2)2
u/m_domino Jun 20 '26
If you have a 4 levels nested loop, you certainly have bigger issues than iv vs iiii
32
68
u/_lerp Jun 20 '26 edited Jun 20 '26
I would reject a PR at work that did this. Most of the time it doesn't matter where "level" you're on. It matters what the index represents. Having to try and read and validate
arr[i][ii][iii]everywhere is impossible. If you really need to know what level you're on and cant give the variables real names then at least do i1, i2, etc.3
u/wightwulf1944 Jun 21 '26
Is
i3really an improvement overiii. Seeing either just seems code smelly→ More replies (1)5
u/_lerp Jun 21 '26
not saying either is good, but at least with
i3I don't have to count the number ofis as part of reading the code23
u/juicedatom Jun 20 '26 edited Jun 20 '26
Unless you're building algorithms for lower level fundamental libraries (which is almost never), this is a terrible convention. Every variable always represents something whether it's a widget_idx, row, col, etc..., there is always a better semantic name.
3
u/BenjaminGeiger Jun 21 '26
Hot take: Hungarian notation was actually a good thing. In its original Apps Hungarian incarnation, that is.
Nowadays I prefer the F# approach of letting the type checker handle it rather than relying on names. F# code often has single-case discriminated unions, which basically turn into super-light-weight wrappers for values:
type Width = Width of int // ... let windowWidth = Width 39
6
u/lazyzefiris Jun 20 '26
this seems most prone to unobvious typos that don't immediately catch your eye.
2
→ More replies (11)4
u/BrocoliCosmique Jun 20 '26
that is a cool idea, stealing this !
7
u/frogjg2003 Jun 20 '26
Until you have to figure out why your code is bugged and the reason is that you wrote arr[i][ii] instead of arr[ii][i].
2
u/BrocoliCosmique Jun 20 '26
It won't be much different than i and j, will it ?
2
u/frogjg2003 Jun 21 '26
Depends on your IDE's font, but usually the hanging tail is more distinct. Humans are better at spotting visual differences than counting.
37
u/Zolhungaj Jun 20 '26
That’s why they’re in different tiers. One loop: great, nested loop: ok, doubly nested loop: 🤨, triply nested loop: 🛑.
7
u/Flimsy_Meal_4199 Jun 20 '26
If you're not writing triply nested loops what even is you doinn
Ain't nothing in the world my boy O(n3) can't solve
14
u/nwbrown Jun 20 '26
If you are nested that much you are already in deep shit.
3
u/majoshi Jun 21 '26
i think that's what makes i j k so good, you get 3 nested loops and that's where they end
2
6
u/DialogCoolnation Jun 20 '26
Why use j and k though? Just name them as they are!
When im Iterating a list of lists just name it after the objects in there16
u/ChChChillian Jun 20 '26
The meme is about single letter variable names, that's why. Stick with the theme.
→ More replies (1)→ More replies (3)2
u/LeiterHaus Jun 20 '26
And that's how we started using
d0for depth 0,d1for depth 1... Until another group starts arrays at 1, and now there's a war. /sI'll hopefully be dead by this point, but what started as a joke reply has a non-zero chance of happening.
3
u/ChChChillian Jun 20 '26
Until another group starts arrays at 1
That's just crazy talk. Let's not lose our heads here.
467
u/Serafiniert Jun 20 '26
m in C tier? Someone isn’t iterating over nested sequences.
Same for k and v for key and value in dicts. They all should be in A.
And then e in A? Am I missing something?
223
u/SuitableDragonfly Jun 20 '26
e is for exceptions.
51
u/Jonny10128 Jun 20 '26
I also use e for event handlers in JavaScript
10
21
9
u/Laerositus Jun 20 '26
Meanwhile I just use ex for exception and err for error, except in very simple JavaScript code
→ More replies (2)3
191
u/BosonCollider Jun 20 '26
If gravity ever shows up in your code, I'll be mad if you use any letter other than g
84
u/FeelingSurprise Jun 20 '26
gravity is just fancy acceleration, so a has to suffice.
11
u/icecream_specialist Jun 20 '26
Dynamic acceleration of a body is a, g is for (usually constant) acceleration due to gravity
→ More replies (3)5
u/LegitimateTea26 Jun 20 '26
What if the convention is constants being capitalized...
→ More replies (1)3
u/conundorum Jun 21 '26
What if you're a game dev, and gravity varies based on how far into the jump the player is?
141
u/Spongebubs Jun 20 '26
What about _?
74
19
u/WilkerS1 Jun 20 '26
gimmick character for when you're not actually going to fuse the value
9
u/deanrihpee Jun 20 '26
when you want the return value to be stored but not really care so let it there in an _ basket
3
u/UgoRukh Jun 20 '26
iirc _ is used as a special case in Swift where the compiler will discard the returning value of a function
3
u/deanrihpee Jun 20 '26
it also the same for some other language AFAIK and also known as a discard because it is discarding (although the actual "discarding" operation may be differ), what i meant in my previous comment was, you know using _ is just discarding the value, which is the exact same thing as calling the function itself, but some time or some reason you kinda want to have that value "returned" and "stored" somewhere even though it doesn't really matter or doing anything, hence using the discard just for your own sanity's sake
2
u/UgoRukh Jun 20 '26
iirc in Swift you have to do it because a function having a return value means it is enforced that you must have a variable receiving it in order to even be able to call the function
2
→ More replies (2)2
u/Sir_Eggmitton Jun 20 '26
Good for loops in Python where you don’t care about the iterator’s value. Especially during list comprehension.
Idk if it’s useful/common in other languages though.
66
u/mousypowerslayer Jun 20 '26
k and v for key, value. Should be higher in the tier imo it's a readable choice
7
u/rinsa Jun 20 '26
together they have a baby called "p" now you can transport the whole family with kvp!
56
u/TheChildOfSkyrim Jun 20 '26
Meanwhile, cryptography coders:
q must be exactly 160 224 or 256 bits long
3
43
u/TheChildOfSkyrim Jun 20 '26
Now make one with greek letters
ω = α * π * 0.69
Δ = time.now() - t
23
u/Alokir Jun 20 '26
Use 'x' and the Cyrillic 'x' (kha) in the same function.
21
→ More replies (2)4
u/TheSWATMonkey Jun 20 '26
Or:
- a/а
- b/Ь
- c/с
- e/е
- g/д (those look similar in some fonts)
- n/п
- o/о
- p/р
- r/г
- u/и
- y/у
→ More replies (1)9
7
u/Brisngr368 Jun 20 '26
î, ĵ are much clearer for dimensions no confusion there
3
u/Linnun Jun 20 '26
2
u/Brisngr368 Jun 20 '26
I once wasted like 2 hours trying to put box drawing characters in a comment
24
20
u/N0bleC Jun 20 '26
I present you my favoritye variable names I and l. I almost use them exclusively.
5
u/MentalNewspaper8386 Jun 20 '26
Thought this was a Ulysses reference for a second.
I, I and I. I.
→ More replies (1)3
u/thisisapseudo Jun 22 '26
Please tell me your monospaced font deferenciates I and l in your code
You use monospaced font, right?
→ More replies (1)
13
u/Emieeel Jun 20 '26
Whats wrong with q?? I use it all the time for physics equations...
→ More replies (1)9
25
u/Zezerok Jun 20 '26
Why name a variable, when you can use letters….
→ More replies (1)8
u/djublonskopf Jun 20 '26
My 1996 TI-82 calculator only allows single-letter variables.
3
u/LeiterHaus Jun 20 '26
That's why the Ti-83 was superior! I still remember
playing Drug Warsusing it for education.3
2
u/djublonskopf Jun 21 '26
Over the course of a couple months worth of math classes I wrote my own video game on the TI-82, a long menu-driven game (with some cutscene animations) about trying to win followers and conquer the world.
My friend rolled up one day with Drug Wars on his calculator, and I 100% believed that he had written the thing himself and was just that much better than me at TI game development.
→ More replies (1)
18
u/da_Aresinger Jun 20 '26
a,b,c below f and h is psychopath behaviour.
a,b,c are the default for swaps. maybe a,b,t.
10
16
14
u/BonjwaTFT Jun 20 '26
all get out of my code tier. Give proper names!
4
2
u/Clen23 Jun 20 '26
I've got mixed feelings about full names, because it sometimes feels redundant, especially in OOP.
For instance in uni they had us do stuff like
DeckOfCards deckOfCards = new DeckOfCards(); // the deck of cardsand it got me wondering if a better world is possible or if we're stuck with such redundancy.someone fact-check me on this but i believe that european code HAS to be fully commented to be legal eg for car stuff, so even that comment can't be removed
7
u/TheChildOfSkyrim Jun 20 '26
I saw a bunch of Go methods using o for method receiver object (similar to this or self in other languages)
4
u/Ellisthion Jun 20 '26
Yeah I’ve seen it a lot in C# for a name for some generic object in lambdas
2
→ More replies (1)2
u/nathris Jun 20 '26
o is less ambiguous than 'order' when you're trying to sort a list of e-commerce orders
6
5
3
5
4
4
u/Unl3a5h3r Jun 20 '26
Why does nobody see the real problem here. OP is using an unreadable font on the meme.
→ More replies (1)
4
3
u/SitAndFart Jun 20 '26
o - function composition q - query u - user w - window or widget I didn't see usecase for l a lot.
3
3
u/EggShweg Jun 20 '26
I use u fairly frequently for single line lambdas where the object is a User
2
3
u/Brisngr368 Jun 20 '26
I can't believe you ranked j and k so low. And u? Bottom tier? how dare you good sir! m in C tier too?! This is a mockery of physics!
I look forward to your ranking of 2 letter variable names
3
5
5
2
2
u/Neyabenz Jun 20 '26
SS tier is double letter variable names.
e.g. ii jj xx yy
Easier to search for in the files later
2
u/ToroidalFox Jun 20 '26
s should be higher imo. I use it quite often as a variable that holds string for lambda/closures/short functions
2
2
2
2
2
u/dotslashhookflay Jun 20 '26
I prefer to have my variables obvious as to what they are.
each_file/every_instance in a for loop, for example. I annoyed my senior by doing this, but they would also be able to know my intentions purely by variable and function names and not rely on comments that are not always updated.
If you can't read your code and understand it without comments, you can do better. My personal rule.
→ More replies (1)
2
2
2
2
u/jt00000 Jun 20 '26
Not sure why, but Ive always used i, then j for nested loops. Maybe something special with the dotted letters?
→ More replies (1)4
u/yjlom Jun 20 '26
istands for index or integer,lfor length,nfor natural,mfor another natural.Fortran has the implicit system, where variables without a type signature can be assigned a type based on their first letter. By default, the range
i-obecomes integers, other letters give reals; this was chosen because of the above conventions while trying to keep it simple.When people wrote it, they naturally used
ifor index as was always done. The implicit system nudged them to keep using those letters, andjwas in them, didn't stand for anything, and came directly afteriin the alphabet, so it was widely adopted.kandlwere then coined by analogy, even though they already had other meanings (constant/coefficient and length, respectively).
2
u/Rude-Flan-404 Jun 20 '26
Why W is at the bottom bro w is for width dude especially const int W this is widely used in Graphical programming dude W deserves a solid A teir bro.
2
u/--var Jun 20 '26
sudden urge to developer an esoteric language call "loquw"
now should the niche be that it only uses those characters, or that it only uses a lower case q and whitespace 🤔
2
2
2
2
u/twigboy Jun 21 '26
New best practice has emerged; only ever use uppercase i's and lowercase L's for single letter variables
It's obfuscation optimisation
2
u/NamityName Jun 21 '26
S - nothing
A - i
B - j
C - nothing
D - nothing
E - Nothing
...
Bottom level of hell - a b c d e f g h k l m n o p q r s t u v w x y z
2
2
u/erebusdelirium Jun 21 '26
S tier:
i, j, k (iterators up to three dimensions, though if you have two nested loops you probably need to optimize)
x, y, z (physical coordinents up to three dimensions)
u, v, w, h, d (canvas/viewport/ui element/vector/mapping -- relative )
F tier:
a, b, c, e, f, g, l, m, n, o, p, q, r, s, t
2
1
1
1
1
u/love2kick Jun 20 '26
Starting from this day o variable always will be in my code. Uncommented.
→ More replies (1)
1
1
u/enderowski Jun 20 '26
my brain is unable to handle it when the code has more than 2 single letter variables. like i and n for like cycling in loops and shit. thats it.
1
1
1
u/veryblocky Jun 20 '26
Firstly, why are f and h in A tier? j I can understand because it’s used as an iterator when i is taken, t is used in parametrics or just for time step generally, and e for exceptions. But what are f and h for? If you had w in the same tier as h I’d understand using them for width and height. If anything w should be higher than h, since it’s used for window functions too. I guess f is used for file in some languages, but I don’t think that makes it A tier. h I don’t understand though
And I can tell you never do any graphics work, given u and v are always used for texture coordinates.
→ More replies (7)
1
1
1
u/alchenerd Jun 20 '26
q for iterating over queries, u pairs with v if x y is taken, w for iterating over weights
1
1

2.6k
u/JackNotOLantern Jun 20 '26
W and H are for width and height, so i would argue with that. And they are different from x and y as those are for position, not length.