Writing shorter code/algorithms, is more efficient (performance)?
performance
Solution
I hope this does not become a flame war. Good code has many attributes, including:
- Solving the use-case properly.
- Readability.
- Maintainability.
- Performance.
- Testability.
- Low memory signature.
- Good user interface.
- Reusability.
The brevity of code is not that important in 21st century programming. It used to be more important when memory was really scarce. Please see this question, including my answer, for books referencing the attributes above.
Problem
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: ``` //Code by: job //Topic: Code Golf - Collatz Conjecture 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?