[erlang-questions] Erlang/YAWS vs Free Pascal/Xitami

Bob Ippolito bob@REDACTED
Wed Mar 26 06:51:24 CET 2008


2008/3/25 Richard A. O'Keefe <ok@REDACTED>:
> On 25 Mar 2008, at 8:58 pm, Jilani Khaldi wrote:
>
>  > Which is better for my web application?
>  > http://www.dotpas.org/cgi-bin/articles/a01
>
>  First, the Erlang code can be substantially simplified to
>
>  var(Xs) ->                      % function name copied from S/S+/R
>      N = length(Xs),
>      Mean = lists:sum(Xs)/N,
>      Centred_Xs = [X - Mean || X <- Xs],
>      lists:sum([X*X || X <- Centred_Xs])/(N-1).
>
>  sd(Xs) ->                       % function name copied from S/S+/R
>      sqrt(var(Xs)).
>
>  out(A) ->
>      Xs = lists:seq(1, 1000),
>      SD = sd(Xs),
>      T  = io_lib:format("Std Dev: ~.6f ", [SD]),
>      {html, T}.
>
>  Second, if you were using Apache, it would make sense to use
>
> org.apache.commons.math.stat.descriptive.moment.Variance
>  to do the variance calculation, and it is clearly "better" to have
>  code just sitting there waiting for you to use it than to have to write
>  it and test it yourself.  (Of course, ideally Erlang would have a
>  'stats:' module with at least mean/1, var/1, and sd/1 in it.)
>
>  But third is most important:  what do you mean by "better"?
>  - Better = it takes you less time to write it?
>    That depends in part on how well you know the language and its
>  libraries.
>  - Better = it is more reliable once written?
>    I'd say Erlang every time; on the other hand these days there are web
>    servers written in Haskell, so you might want the security of strong
>    (polymorphic) typing as well as the safety of assignment-freedom.
>  - Better = runs in less time on your machine?
>    First get it working, then measure.  Once it is fast enough, stop
>  worrying.
>    "Fast enough" depends on workload, of course.
>  - Better = runs in less memory on your machine?
>    For an application that only needs one process, Pascal is likely to
>  do
>    better than Erlang here.  For an application that needs many
>  processes,
>    Erlang is likely to do better than Pascal.
>

Another thing to consider is hot code reloading, if you're maintaining
any state in these processes. We've had really good experiences with
Erlang overall, especially performance (relative to Python, not
Pascal), but hot code reloading is still one of my favorite features
and I'd certainly be willing to trade some performance to have it (for
long-running servers).

-bob



More information about the erlang-questions mailing list