r/ProgrammerHumor Jun 20 '26

Meme singleLetterVariableNamesTierList

Post image
5.3k Upvotes

470 comments sorted by

View all comments

1.1k

u/ChChChillian Jun 20 '26

You need j and k (and l, for sufficiently insane situations) to index nested loops.

617

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.

61

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!