http://qs321.pair.com?node_id=438908


in reply to Efficiency and length of variable names

In answer to your question, larger variable and subroutine names will certainly take up more memory than shorter ones. In most programs and scripts the difference in performance however is so minor (i.e. almost negligible) as to not be a real concern.

If speed is of the utmost priority there are a number of programming style points which have a more significant impact on performance than the length of names; using hashes instead of linear searches, using next if to reject common cases early before you split or chop, avoiding regular expressions with many quantifiers and using s/// when concatenating strings to name a couple of examples. You might find it worth your while to read the Efficiency section (Chapter 8 Section 8.3) of Programming Perl.

Remember, however, that there are different types of efficiency (such as space and readability/maintainability) and some of them aren't worth sacrificing for speed. Writing code with one-letter global variable names might give you a slight speed advantage now, but if you won't recognise what they symbolise when you come to re-visit the code in six months you're going to waste valuable programming time.

-- rozallin
rozallin@livejournal.com