Joe wrote:
On Aug 02, 2006, at 11:05 UTC, Theodore H. Smith wrote:
The thing I don't understand that no one mentioned, not even the
article, is that fast code is usually maintainable code and code
that's quicker to write.
That's because less code = faster code. less code = quicker to
write and maintain.
That's not mentioned because, in general, it is patently untrue.
Quite the opposite: speed-optimised code is usually longer, more
complex, and far more obtuse than unoptimised code.
Code that's short, clean, and efficient doesn't count as optimised
code; that's just good code. We all write that way whenever we
can. But serious optimization will require much more complex
tricks, like loop reordering for data locality, changing to a more
complex (but efficient) algorithm, etc.
Like Theo's statement, your statement is just as incorrect in the
opposite direction. Your assumption that there exists a linear
relationship between code complexity and the state of optimization
is false. There is no explicit relationship between the complexity
of the code and its optimized state. If you were handed a piece of
code and told to optimize it, sometimes making the code simpler is
the optimal solution. Other times adding code that allows you to
skip steps is the optimal solution. Since cases exist for both
directions, then it shows that the two variables of complexity and
optimization are not related. If you take Theo's point of view,
you will miss set of optimizations that could be applied. If you
take your point of view, you will also miss a set of optimizations
that could be applied. Optimization is function of the forethought
put into the code and the complexity or simplicity of the code is
just the result of the forethought.
Though Theo's assertion is not correct in the context in which he
presents it, it does have some truth to it in a bizarre twisted
way. People who create maintainable code are far more likely to
write optimized code! People who are sloppy in writing their code
are more likely to not write optimized code since their code is
more difficult to manipulate.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>