Declaring a variable name, how much (if at all) impact does the length of its name have to the total memory of the application? Is there a maximum length anyway? Or are we free to elaborate on our variables (and instances) as much as we want?
And yes, it uses memory, but it's the compiler's memory, not anything at runtime for your program.
Variable name will have absolutely no influence at runtime, and totally negligible at compile time.
Compiled-to-bytecode languages tend to not have reflection at all, so the variable names don't matter. Some languages may have a limit: though not imposing it as a rule for the source code, internally the variable name may be truncated to say 32 ascii characters.
To wrap it up, variable name length can affect a Python program's speed as larger files require longer processing times, as shown in the Unix time benchmark.
It depends on the language, actually.
If you're using C++ or C, it has no impact.
If you're using an interpreted language, you're passing the source code around, so it can have a dramatic impact.
If you're using a compiled language that compiles to an intermediate language, such as Java or any of the .NET languages, then typically the variable names, class names, method names, etc are all part of the IL. Having longer method names will have an impact. However, if you later run through an obfuscator, this goes away, since the obfuscator will rename everything to (typically) very short names. This is why obfuscation often gives performance impacts.
However, I will strongly suggest using long, descriptive variable/method/class names. This makes your code understandable, maintainable, and readable - in the long run, that far outweighs any slight perf. benefit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With