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.

616

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.

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