Writing shorter code/algorithms, is more efficient (performance)?
Posted
by Carlos
on Stack Overflow
See other posts from Stack Overflow
or by Carlos
Published on 2010-03-08T06:58:11Z
Indexed on
2010/03/08
7:06 UTC
Read the original article
Hit count: 248
After coming across the code golf trivia around the site it is obvious people try to find ways to write code and algorithms as short as the possibly can in terms of characters, lines and total size, even if that means writing something like:
n=input()
while n>1:n=(n/2,n*3+1)[n%2];print n
So as a beginner I start to wonder whether size actually matters :D. It is obviously a very subjective question highly dependent on the actual code being used, but what is the rule of thumb in the real world.
In the case that size wont matter, how come then we don't focus more on performance rather than size?
© Stack Overflow or respective owner