[erlang-questions] Erlang arithmetics

Jesper Louis Andersen <>
Sat Oct 30 23:22:50 CEST 2010


On Sat, Oct 30, 2010 at 10:42 PM, Max Lapshin <> wrote:
> Would you, kindly, provide an example with such optimized code? I
> couldn't reproduce it with my benchmarks.

If type inference already figures the type information out correctly,
it should definitely be the same speed these two run with.

Another point from the original: The Javascript version creates an
Array which is filled before the initial run. In contrast, the Erlang
version stores this in a singly linked list. So when the main
calculation body runs, the Erlang versions suffers from having to walk
the list whereas the Java version might be able to utilize that the
array has a more cache-friendly behaviour. When you are doing
benchmarks this synthetic, I think it may have a large effect on the
speed.

Also, this is a pet peeve of mine: Measuring the usefulness of a
language by a few benchmarks is probably not going to give a fair
survey of the question. As many people have already pointed out, they
would solve the problem differently. I, for instance, would never
first build up a singly-linked list of random numbers and then consume
it afterwards. In Haskell I would, because fusion optimizations will
trigger in Haskell, but in Erlang I would try to avoid
generation/consumption constructions.

As for Node.js vs Erlang, the real trouble with "Number Crunching
problems" is that Ocaml, C++, Java, C or Fortran is an order of
magnitude faster, usually. It would therefore be much smarter, for
Node.js or Erlang, to utilize the effort put into these languages for
the problem at hand and interface with them.


-- 
J.


More information about the erlang-questions mailing list