Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Coz

Memory and variable names

This topic is 5602 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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....

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!