[erlang-questions] some language changes

ok ok@REDACTED
Wed Jun 6 02:58:21 CEST 2007


On 5 Jun 2007, at 5:26 pm, Paul Mineiro wrote:
[C function goes ok in Haskell using Word32 but slowly using Integer
  -- there is no BigInt in Haskell --; goes slowly in Erlang using
  big-enough integers, would something like Word32 be possible in  
Erlang?]

Haskell uses strong static typing (stronger by far than C, C++, or  
Java).
This means that when strictness analysis can get rid of the "is-it-
evaluated-yet" stuff, machine-size integers are put in machine-size  
words
with no overheads.

Erlang uses dynamic typing.  Every value has to have a tag (a few bits
stolen from somewhere in a machine word) to say what kind of value it  
is.
One of those tags will say "Small integer", and one of them will say
"Large integer".  Small integers will be somewhere between 24 and 30  
bits.
If you want 32-bit values, they will have to be put somewhere else and
pointed to, so for stuff that really needs 32-bit integers, no, there is
no easy way to get the performance you want in Erlang.

It is a pity the algorithm is "a (proprietary) function", because the
chances are excellent that there is another way to express it that  
doesn't
need large integers (or not often).  The more you can tell us about the
character of your problem the better the advice we can give.





More information about the erlang-questions mailing list