Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are long variable names a waste of memory?

If I have an variable int d; // some comment. Will that be better than int daysElapsedSinceBlahBlahBlahBlah with no comment. It is more reabale, but will it waste memory?

like image 862
javaguy Avatar asked Nov 30 '22 13:11

javaguy


1 Answers

You marked this as language-agnostic but the example corresponds to C-languages family. In C-like languages the name of the variable shouldn't waste memory, it's just a label for the compiler. In the resulting binary code it will be replaced by a memory address.

In general, there is no benefit in storing the name of variable inside resulting binary, the only usages I can think of is some extreme debug, reverse-engineering or some weird form of reflection. None of these are normal use-cases.

like image 136
SomeWittyUsername Avatar answered Dec 05 '22 07:12

SomeWittyUsername