[erlang-questions] Anonymous functions and performance

Jon Watte jwatte@REDACTED
Sat Nov 5 00:41:01 CET 2011

To be fair: the kinds of "premature optimizations" that Knuth was talking
about when he wrote that were worrying about individual instruction
selection based on expressions in a high-level program, and/or re-coding
some statement using inline assembly. Specifically, the quote is prefaced
with an admonition to ignore "efficiencies in the small" "about 97% of the

What he did *not* say was that we should ignore performance altogether --
or even that we shouldn't care about performance before and during bring-up
of our programs. In fact, the point of the article is that you should worry
about the big performance things first -- I/O, algorithms, data structures.
Only when all of those are optimal, does it make sense to do small-scale
optimizations that give you some constant factor of speed-up.

I recommend you read it; the whole thing. It doesn't say anything like "you
shouldn't consider overall performance when you're writing code;" rather
the inverse! Design for performance; implement for clarity.



Americans might object: there is no way we would sacrifice our living
standards for the benefit of people in the rest of the world. Nevertheless,
whether we get there willingly or not, we shall soon have lower consumption
rates, because our present rates are unsustainable.

On Thu, Nov 3, 2011 at 6:35 PM, Richard O'Keefe <ok@REDACTED> wrote:

> On 2/11/2011, at 11:08 PM, Joe Armstrong wrote:
> > When the great old ones said years ago "Premature optimization
> > is the root of all evil" - they were using machines that by todays
> > standards were
> > incredibly slow. Even then they viewed premature optimization as evil.
> Mind you, premature pessimisation isn't a good idea.
> I'm in the middle of a, um, discussion about the marking of two
> student projects.  Both of them involved comparing the performance
> of some algorithms.  Both of them had code that was a factor of
> 4 to 6 *thousand* times slower than straightforward C.  I think
> that this makes their results meaningless, or at any rate useless,
> and that a project with such results deserves a low mark.  On the
> other side it is argued that these are well presented projects...
> Straightforward code using straightforward data structures is the aim.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20111104/0e097f07/attachment.htm>

More information about the erlang-questions mailing list