Erlang Efficiency quesitons

Chris Pressey <>
Thu Mar 15 20:17:43 CET 2001

James Hague wrote:
> Eight bytes per character bugs me as much as anyone, but in all honesty is
> string processing in Erlang really blindingly slow compared to other
> languages? For simple filters, Perl walks all over Erlang, but for parsing
> and such I'm not sure.

Since Perl is (presumably!) optimized for text-handling, comparing
Erlang against it probably isn't a fair or realistic comparison. 
Compared instead to a language with less emphasis on
string-manipulation, for example Visual Basic perhaps, Erlang's string
performance seems perfectly adequate.  (i.e. VB strings are just as
slow, or were the last time I used VB anyway.)

> Even if Erlang is a bit below average in the string
> processing department, the performance of the rest of the language is better
> than any interpreted language I have used. Heck, even in toy benchmarks it
> walks all over some compiled Lisps.

In my experience, raw speed is not as important as the "perception of
timeliness".  Erlang might have some points against it speed-wise (I've
found it's really easy to accidentally write O(N^2) or slower
algorithms,) but it has a huge point for it with regards to how fast it
*seems* to go.  The lightweight processes and fair dispatching give the
impression of smooth, almost continuous operation.  Compared to programs
written in Perl and even C++ which can seem to run choppily.  For many
people, choppy operation is more disconcerting than slow operation, all
other things being equal (hey, you can always get a faster computer...)

> It would be trivial to justuse  binaries instead of strings as it is, I
> think.  I rewrote a custom lexer to use binaries instead of lists, and it
> ended up much cleaner.

I like some of the ramifications of optimizing strings.  For example
Erlang programs would compile a bit quicker (unless I'm profoundly
mistaken about how the compiler works.)


"Ten short days ago all I could look forward to was a dead-end job as a
engineer.  Now I have a promising future and make really big Zorkmids."
Chris Pressey, Cat's Eye Technologies,
Esoteric Topics Mailing List:

More information about the erlang-questions mailing list