Skip to main content
gamedev.net
🔒 Locked

Memory and variable names

Started by Coz Jan 23, 2003 at 11:35 AM 2 replies 200+ views
Original Post
Coz
Coz
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?
Martee
Martee
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
BitMaster
BitMaster
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.
dede
dede
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....

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.