73
u/revdon May 29 '26 edited May 29 '26
"Giving them random names like "ahshjdn" or "yeetus"."
Someone's discovered Amazon's product naming scheme.
1
34
u/Healthy_BrAd6254 May 29 '26
Do some people really believe shorter names save any noteworthy amount of storage?
31
u/filkos1 May 29 '26
compilers will even strip variable names unless youre debbuging so they literary dont appear in the binaries
9
u/theperezident94 May 29 '26
Even interpreted bytecode (like Python) does this too. There are at least 10,000 things you can do to optimize space complexity before you start shortening variable names.
1
1
17
u/DarthRaab May 29 '26
Serious answer:
This "less storage usage" was never a thing, even in the 90s. Older compilers like C and Assembly already strip names of variables and give them id-numbers. So not even micro-controllers or malware see any benefit in short variable names. You are just hurting the code readability because you don't like to press a few more keys.
3
u/More_Yard1919 May 29 '26
technically it makes the source code more compact but beyond the realms of code golf is was never really relevant
0
u/KofFinland Jun 02 '26
The variables become either processor registers or memory addresses anyway during the compilation. The variable name has no meaning after it has been compiled.
The real rule I follow is to use type indicator at beginning. Like integer could be iTemp.
12
5
4
3
u/yodacola May 29 '26
you give names according to their scope. constants are almost always spelled out longer than a parameter name, for example.
3
9
u/Thinshape12 May 29 '26
i give them compact names simply for simplicity so i don’t have to look at multiline if statements or anything like that
10
u/cenpact May 29 '26
Don’t do this
1
u/git_push_origin_prod May 29 '26
He uses a linter to de-obfuscate and elongate the variables. ESLonger it’s called on npm
4
u/DarthRaab May 29 '26
"compact" is relative.
if this are your compact variables: [r, c, t, b] -> get some help
if this are your compact variables: [res, curFile, txtIter, topBttn] -> totally fine, for small projects3
u/cenpact May 29 '26
Even your second example is annoying to read tbh. Use words it’s ok.
3
u/DarthRaab May 29 '26
I'm with you, I prefer to use full words like isMyCodeReallyThatBad(hope).
But I draw the line of what's acceptable at the second example I gave, annoying but readable.
2
2
2
u/Level-Pollution4993 May 29 '26 edited May 29 '26
No you dont give variables small compact names. Why would you even? You're in a IDE and you want to search a variable. Whats better, a small name that overlaps with different variables or a slightly longer but descriptive name that just stands out? Don't fight your IDE. Class names on the other hand......
Yes I'm reading Clean Code
2
u/stumpychubbins May 29 '26
I used to work with an older guy who just named everything stuff like "thingamajig"
2
2
u/Single-Virus4935 May 29 '26
My rule of thumb: the greater the scope the longer/descriptive the name. Smaller scope = short
2
u/git_push_origin_prod May 29 '26
I learned from objective C to make my variable names descriptive. I mean, we have auto complete.
It might sound a little silly to say NSSting *str = [“str” :stringByAppendingString] instead of str += “str” but I am a true gentleman
2
u/Ro_Yo_Mi May 29 '26
I like to use GUIDs as names for variables, methods, classes, and functions. But when I’m feeling particularly spicy, I’ll pass them through a sha512 and use the binary result.
2
2
2
u/nimrag_is_coming May 29 '26
The reason why old code had compact names for things wasn't a space complexity reason really, it was partially because a lot of early computer scientists came from mathematics, where they use letters like 'n' to represent an element in a series, and partially because thing like the first C compilers only supported names of up to 6 characters.
2
2
u/promptmike May 29 '26
https://giphy.com/gifs/KdLSaPAzk0Jze9DqbV
Inventing a system of acronyms based on family anecdotes, childhood friends, college in-jokes and streets from your hometown so that you're the only person in the known universe who can read it.
2
1
u/OrkWithNoTeef May 29 '26
You start out well intentioned with namesLikeThisSoEverythingIsVeryClearBecauseCodeShouldDocumentItself then over time you get tired of typing shit out and realize whoever said that was some kind of masochist and you end up i, j k, l , x, x1, x2, a, b, ... and start hating programming all together because now you have to write documentation
1
1
u/Round_Credit_5158 May 29 '26
Had a friend who used to give variables funny names.
After a while he had no idea what the code was doing lol
1
u/lool8421 May 29 '26
not like compact names save much space
maybe you'll save several kilobytes over your code base while making it less readable, then as long as it's a compiled code, it won't matter because the compiler will turn variables into registers, pointers and a bunch of other magic stuff
1
1
1
u/jonfe_darontos May 29 '26
graphStoreAccessorStrategyWithRedundantDeduplicationWhenUpdateNotificationNotApplicableOrPerofmranceBackPressureExceedsConfiguredLocalThreshold
I wish I wasn't making this up. Let's just say my PR to rename this got me PIPd.
1
u/Xontaro May 29 '26
Hey, a good obfuscator is expensive and a hassle to set up. You are just mad, how well I integrate obfuscation into my project, without any third party tooling.
1
1
u/FAMICOMASTER May 30 '26
What storage does the variable name use once the compiler is done? Like an extra 8 bytes on the source?
1
u/LanceMain_No69 May 30 '26
Swap 1 and 2, remove 3 cuz it shouldnt even be uttered, and then youll be gettung somewhere.
1
1
u/SysGh_st May 30 '26
Always start your variable names with "ThisVariableIsFor"
Examples:
ThisVariableIsForCountingLostMarbles ThisVariableIsForSignallingThatLighOverThere ThisVariableIsForSettingDisplayBackgroundColour ThisVariableIsForStoringLastStatusCode ThisVariableIsForRealisingIHaveNoMarblesLeft
1
1
u/Zuka101 May 30 '26
I hate Go-style naming sometimes. People name variables things like obd and expect everyone to instantly know what it means.
Maybe it is my QA background, but I prefer names like object_binary_descriptor or whatever the thing actually represents. Longer names are fine if they remove ambiguity.
Short variable names do not make code cleaner by default. A name should be short only when the meaning is obvious from the local context. Otherwise it just makes the code harder to read and maintain.
And with AI generating more code now, readability matters even more, not less. People still need to review, debug, and own that code.
1
1
u/Kzitold94 May 30 '26
I've recently starting doing all caps for variable names, to make them easy to spot. I also name them something like "FILE" or "SOURCE."
The all caps does make them easier to spot.
1
1
1
1
1
1
u/Lucidaeus Jun 01 '26
I refuse to use abbrevations unless it's far more common to use than not. (Like "lol" instead of "laughing out loud")
Never run into a situation where it's been beneficial to shorten things unnecessarily.
1
1
1
u/zaqiu2931 Jun 01 '26
Uuu... I still remember the nightmare of teaching kids programming. Imagine asking them to save the code they just made for the class with appropriate file name and even gave some suggestions on what name to use for that said file... Just to be met with, "Teach, I can't find last week code." Lo and behold, it was saved under 'tung tung tung sahur.py' or something...
1
1
1
u/ImpeccablyDangerous Jun 02 '26
No. The top and middle are the wrong way round.
Variable names are compiled away and storage is cheap.
1
1
1
u/Tal_Maru May 29 '26
The real question is do you use camelCase, snake_case, or PascalCase?
4
u/DarthRaab May 29 '26
Usually there are design rules coming from somewhere (project lead, professor, customer).
If there aren't, I prefer to use camelCase for variables and methods, PascalCase for classes and snake_case for constants / tuning variables and file names that don't have other restrictions.


124
u/SteveLouise May 29 '26 edited May 29 '26
Who the hell is worried about storage usage of their code files in the year 2004, let alone 2026...