Elektrine lite

← Feed

@Quetzalcutlass@lemmy.world

2026-10-25 06:20 UTC

I disagree when it comes to standardized single-letter variable names. They’re invaluable when writing dense code for games or other math-heavy applications and you learn to recognize them very quickly. So i for index in loops (and j, k for nested loops, but you’re almost always doing something wrong if you need them); x, y, z for position and h, w for size; r, g, b, a for color data, etc - you’ll immediately know what the variable is for at a glance even though it’s a single character.

Replies (1)

  • @kionay@lemmy.world 2026-10-25 15:33

    I can concede that in games programming (which I’m not a game dev so I often forget about) x, y, and z coordinates are a valid exception. I would disagree about w and h for width and height, typing them out feels like i for index I worry about the phrase, “you’ll immediately know what the variable is for at a glance even though it’s a single character” how often have you heard developers say that something is simple and it’s just because they wrote it? maybe it is obvious, but if it were more verbose it would be just as obvious but without any possibility of misunderstanding and even if it’s obvious now there’s no guarantee a future developer doesn’t pull that variable out and mutate it or do something else with it, and maybe they should change it at that point but the effort to have it verbosely named from the start is miniscule

    Open ##5241246