[erlang-questions] At what point am I "playing compiler"
Tue May 19 23:18:35 CEST 2009
On 18-May-09, at 7:03 PM, John Haugeland wrote:
>> Knuth also wrote (though I can't find the reference) that it was not
>> worth optimising
>> something that got called less that 10^9 times (I think that's right)
>> - he wrote that something like 20 years ago, so today the advice must
>> be 10^12 times :-)
> This isn't, of course, meant to be taken literally, ...
> This is a bit like quoting e=mc^2 : there are actually a bunch of
> things removed from that in order to make it brief and pithy enough to
> use as a rule of thumb. ...
Ah, but the *more common* behaviour is to optimise unnecessarily, not
to reject optimisation where it's merited (how would that fly for
If it's needed, it's needed. If it's not, it's not. That is a rule of
thumb that is essentially Knuth's rephrased. Your "counterexample"
was obviously a case that was "needed" because it's built into your
requirements: "I would prefer this to take days, rather than months".
Or, you never realised it could be made orders of magnitude faster
until you fixed a design flaw. (Optimisation by accident.)
> We're scientists. We don't pick numbers like 10^9 out of the air.
> Knuth, hallowed be his name, was merely giving the range as an
> observation to prevent people from sweating single cycles out of their
> bash scripts. Constructing valid counterexamples is trivial for a
> college freshman.
> Skepticism in all things is the basis of deep understanding.
...and that includes skepticism about the reflex and attendant
"rationalisations" for micro-optimising early. (Which is just wasting
a different and more valuable resource.)
> erlang-questions mailing list
More information about the erlang-questions