397
Choose your path! (feddit.org)
you are viewing a single comment's thread
view the rest of the comments
[-] red_tomato@lemmy.world 9 points 2 days ago* (last edited 2 days ago)

Outside of the for loop counters i and j, short variable names are awful.

I’ve started to prefer writing it out as ”index” or ”iteration” even in for loop counters. It’s easier to read, and not much harder to type.

[-] FishFace@piefed.social 7 points 2 days ago

Keeping things that can be on one line to one line is a good reason to use short variable names where it won't be confusing. Writing "iteration" sounds absolutely perverse!

The thing is, everyone understands i and j. The reason calling variables hcv or iid is dumb is because noone knows what that means - quite a different situation.

[-] red_tomato@lemmy.world 5 points 2 days ago

Writing “iteration” sounds absolutely perverse!

I like it to make it clear when the for loop is about iterating lists and when it’s not. For example, the iterations in Monte Carlo algorithms doesn’t correspond to items in a list.

[-] silasmariner@programming.dev 5 points 2 days ago

idx is the ideal name for an index, change my mind

[-] sukhmel@programming.dev 8 points 2 days ago

Yh, y cn sv a lt f spc wtht ths unncssr vwls

[-] silasmariner@programming.dev 3 points 2 days ago* (last edited 2 days ago)

I is a vowel too but you sure can!

Edit: also I noticed you dropped one 'y' but not the others. Is this an accident or some subtlety to do with y's 'semi-vowel' status? To be discussed.

[-] luciferofastora@feddit.org 3 points 2 days ago

t's prbbl t kp wrds rcgnzbl. Hw ls wld knw wht h s sppsd t b?

[-] sukhmel@programming.dev 2 points 2 days ago

I had to leave most of first letters, and sometimes if all vowels are removed there's nothing left

But yeah, we need a committee and come up with a standard for that

[-] Dhs92@piefed.social 3 points 2 days ago

I think even idx is better than just i. I feel like just i can visually get lost

[-] masterspace@lemmy.ca 3 points 2 days ago

I typically do too, or userIndex or something for nested loops, but I will accept i and j for the first two levels of nesting when reviewing a PR because they're such a convention. I wouldn't accept variable names like that anywhere else though and try and avoid them myself.

this post was submitted on 11 Jan 2026
397 points (92.3% liked)

Programmer Humor

28421 readers
1870 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS