Page 1 of 1

Do longer variable names use more memory?

Posted: Thu Oct 12, 2023 8:01 pm
by wysardry
If you have two almost identical programs, where one uses the variable name LongVariableName and the other uses LVN, would the former use more memory space after compilation?

Re: Do longer variable names use more memory?

Posted: Sat Oct 14, 2023 10:02 am
by spotlessmind1975
hi wysardry!
wysardry wrote: Thu Oct 12, 2023 8:01 pm would the former use more memory space after compilation?
Absolutely not: the length of the name of the variables does not influence in any way the length of the program that uses them.

From a technical point of view, each "variable" is nothing more than a direct and/or indirect references to memory locations. Therefore, the fact that these references have a long or short name has no effect on the final executable, because it will only use it as a shortcut for a memory address, that occupies always 8 or 16 bits.