optimization of list comprehensions
Ulf Wiger (AL/EAB)
Thu Mar 9 15:45:01 CET 2006
In the face of Mats's convincing evidence and my
own inability to calculate percentages, I must concede
the point, at least as regards AXD 301 & derivatives.
One should perhaps note that, at least for programmers
reared in the AXD 301 environment, funs were initially
slow and had a tendency to break during upgrade. Also,
using list comprehensions would be about twice as slow
as hand-coded iterator functions.
These problems have long since been fixed, but
perceptions have a tendency to linger, especially in
a conservative setting, like doing maintenance on a
> -----Original Message-----
> From: owner-erlang-questions@REDACTED
> [mailto:owner-erlang-questions@REDACTED] On Behalf Of Mats Cronqvist
> Sent: den 9 mars 2006 15:01
> To: erlang-questions@REDACTED
> Subject: Re: optimization of list comprehensions
> Richard A. O'Keefe wrote:
> > If you have evidence to back this up, it's publishable.
> > Please publish it. Some sort of survey analysing what
> kind of > programmers use what kind of language features
> would be most illuminating.
> Ulf Wiger (AL/EAB) wrote:
> > I think it's safe to say that even "average" industrial programmers
> > rather quickly learn to exploit the virtues of higher-order
> > and iterators.
> not to be outdone by wiger (and since o'keefe said
> please), i ran a few greps on 1,748,162 lines of erlang
> sources (comments included). i estimate that some 3-400
> people have contributed to the code sample.
> i counted how many times each of the patterns below
> appeared per module.
> "[ (]fun[ (]" "lists:fold" "lists:map" "lists:foreach"
> never 64% 89% 84% 85%
> <3 times 81% 97% 94% 94%
> 36% of the modules defined at least one fun. however, 15%
> of all modules had at least one call to mnesia:transaction.
> so i feel pretty confident stating that
> ~80% of all modules have no (non-mnesia related) funs.
> another observation is that although there were ~2 fun
> definition per module, 4% of the modules accounts for 50% of
> the fun definitions.
> one possible interpretation is that most of this code was
> produced by programmers that rarely use funs if they don't
> have to. obviously, the methodology is much too weak to
> *prove* this. i'm not sure it can be proven, since there's no
> way to establish who wrote what. most modules have been
> touched by at least a handful of people, and everyone has
> worked on more than one module.
> note also that most of this code sample has been used for
> years in a very challenging environment, and is part of one
> of the most stable products in its market.
> i does seem safe to say that one can write well working
> Erlang code while rarely, if ever, using funs (excluding
> mnesia use, as always).
More information about the erlang-questions