Memory and variable names

Started by
2 comments, last by Coz 21 years, 3 months ago
Does a integer named GameState is used faster, initalized faster or has any performance or memory disadvantage against the same variable with a shorter name, like GState?
Advertisement
No. There is no difference whatsoever between the two. Variable names are for you, and you only, and have no effect on the resulting code (*).



* Debug information notwithstanding.
ReactOS - an Open-source operating system compatible with Windows NT apps and drivers
If we are talking about compiled code: No difference at all. Actually the name of a variable is completely dropped during compilation.
If we are talking about interpreted code: Longer names will have a slightly higher overhead (parsing the name takes longer). How much overhead beyond that depends on the design. But all in all I would say if you can use an interpreted language for your problem, then variable name length is not an issue in any case.
Precompiled code depends entirely on the implementation.
The only perfomance a shorter name might gain is Lines of Code per Day.

writting GState a hundred times in code is much faster than writting GameState, and is way faster than writting:
fhajohgsasdfasfgdfgdfhdshghfghfdghdfgas

That is usually why programmer prefer GState to GameState, cuts down on programmer''s work, as long as that programmer can remember that GState means GameState....
~~~~~Screaming Statue Software. | OpenGL FontLibWhy does Data talk to the computer? Surely he's Wi-Fi enabled... - phaseburn

This topic is closed to new replies.

Advertisement