R
Ray Dillinger
Rahul said:Of course, the issue of a compiler's quality of code generation is just
a constant-factor improvement. Being able to redirect programmer time
towards improving the algorithm and allowing the programmer to explore
the problem and solution space to discover better algorithms might make
the problem take O(n) time instead of O(n^4) time.
This is not quite true. I've seen and used compilers that did all sorts of
nifty tricks with pure-functional routines. I've had order(n!) source code
compile to order(n) object code using ART*Lisp, for example: the compiler
memoized the function to eliminate a (stupid, mea culpa) branching recursion.
In side-effect-o-rama languages like c/c++, this is almost never worthwhile
because provably pure-functional routines are rare. But in Lisps, once people
get the hang of it and if you can keep them from using mutable objects for
everything, well over 90% of all functions are pure functional (ie, cause no
side-effects and are unaffected by anything other than their arguments).
Compilers can aggressively memoize or even algebraically rewrite such functions,
not just to reduce by a constant factor, but to lower their order of complexity.
Bear