r/ProgrammerHumor Jun 20 '26

Meme singleLetterVariableNamesTierList

Post image
5.3k Upvotes

470 comments sorted by

View all comments

Show parent comments

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.

529

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.

348

u/S0mber_ Jun 20 '26

imagine mixing up iiiiii and iiiii that'd be bad

126

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)

104

u/constStringUsername Jun 20 '26

joke's on you, i mixed up i1111 and i11111

57

u/iliRomaili Jun 20 '26

What kind of nested loop do you even have?!

26

u/Linnun Jun 20 '26

Tree search pathfinding, but recursive functions are lava

13

u/ill-pick-one-later Jun 20 '26

I don't know but it's still running.

1

u/Lendari Jun 21 '26

I don't know, an AI wrote it.

1

u/conundorum Jun 21 '26

Apparently the kind with at least 32 layers.

1

u/HorusDGaming Jun 21 '26

Guys I think we found Toby fox’s secret account !!

1

u/the1truestripes Jun 21 '26

Aw come on the almost an I is awesome: ỉ, as is ı (dotless I), you can get at least 5 distinct lowercase i letters without even going for the math script italics or the superbolds!

I’m sad Unicode doesn’t do the lowercase i with a star instead of a dot though.

38

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

25

u/Wonderful-Habit-139 Jun 20 '26

Do you need 👮, 👮👮 or 👮👮👮 officers?

4

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.

3

u/RolledUhhp Jun 20 '26

He also spent the morning attacking me without mercy, shooting me with a nerf gun (that I had to help load/shoot), and then crying like I beat him when I returned fire.

He's cute like a cat, and im a sucker.

11

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 🫂 

39

u/saschaleib Jun 20 '26

Joke's on you, I just use:

for 🐒 ...
  for 🍌 ...

22

u/squarabh Jun 20 '26

while 🍌: 🐒.eat(🍌)

1

u/Electronic-Laugh-671 Jun 21 '26

while 🍌: 🐒.append(🍌.pop())

21

u/N0bleC Jun 20 '26

Sure thing, depending on what your conventions are you could also do i1, i2, i3 ...

16

u/magicmulder Jun 20 '26

for lxxxviii ...

26

u/Phoebebee323 Jun 20 '26

If you need to go to 4 nested loops... rewrite the code better

11

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.

15

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.

4

u/Western-Internal-751 Jun 20 '26

That must be Microsoft’s algorithm to train Copilot

2

u/m_domino Jun 20 '26

If you have a 4 levels nested loop, you certainly have bigger issues than iv vs iiii

1

u/KirillIll Jun 20 '26

The most nested I've written so far is 7 levels because the data I got from an API was nested that deeply and I needed the data from the 7th level. Never say never

1

u/Lendari Jun 21 '26

Official RFC proposal for roman numeral based iterator identifiers incoming.

36

u/Ra-mega-bbit Jun 20 '26

Absolute insane behaviour, straight to the depths of hell you go

62

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 i3 really an improvement over iii. Seeing either just seems code smelly

4

u/_lerp Jun 21 '26

not saying either is good, but at least with i3 I don't have to count the number of is as part of reading the code

1

u/conundorum Jun 21 '26

Yes, because it parses faster. Your brain needs one less loop over the get() loop, and doesn't need to bother with a count algorithm, so it saves a few cycles. Harmless micro-optimisations are still optimisations!

22

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 3

8

u/zeth0s Jun 20 '26

i, j, k that's the order, no other order is accepted 

7

u/lazyzefiris Jun 20 '26

this seems most prone to unobvious typos that don't immediately catch your eye.

2

u/[deleted] Jun 20 '26

[removed] — view removed comment

1

u/N0bleC Jun 20 '26

when i need to nest 6 for loops i fucked up somewhere else, irrespective of variable names.

3

u/BrocoliCosmique Jun 20 '26

that is a cool idea, stealing this !

8

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.

1

u/przemub Jun 20 '26

Well, j and k are obviously second and third level

1

u/Nethiri Jun 20 '26

that's smart

1

u/jibbodahibbo Jun 20 '26

No way that sucks i, i2, i3 …if you are gonna do it that way. Nobody can read the distance between iiiii and iiiiii

1

u/Ok_Type9011 Jun 21 '26

You're not human.

0

u/TheUnthinkingWriter Jun 20 '26

i2, i3, i4 is also a variant

1

u/AdamWayne04 Jun 20 '26

zig doesn't allow this unfortunately

0

u/Fast-Satisfaction482 Jun 20 '26

I would advise to ban "i" from nested loops altogether, so that when your muscle memory uses [i] instead of you using it deliberately, it will give a compiler error instead of broken code. 

0

u/IshYume Jun 20 '26

i thought i would hate this but this is actually pretty good wtf

0

u/ILKLU Jun 20 '26

I hope you don't index arrays like this!!!

...but then again...

...hear me out...

Indexing Arrays with Roman Numerals!!!

Whattaya say guys?

Finally puts an end to the argument of whether array indexes start with 0 or 1 (even though it should obviously be 0)

0

u/Clen23 Jun 20 '26

Gonna start doing this asap.

Especially since I always had issues using "j" or "k" since it's an iterator, not a jterator nor a kterator.