[erlang-questions] surprise! binary vs list in file parse.

Jesper Louis Andersen <>
Thu Jun 26 17:02:46 CEST 2008


2008/6/26 litao cheng <>:
> I had read joel's article:Parsing text and binary files with Erlang. In the
> article, the author show how to parse a comma-delimited text file.
> I write the code for practice, the module source is act.erl.  By the way, I
> see in the bottom of joel' article, a buddy give a comment, he says, he use
> binary to instead of some list, It seems so efficient, so I write the second
> code, it's act_2.erl.

In addition to Vlads suggestion, you might want to know that there are
considerable improvements
to binaries in R12B compared to R11B. Many "stock erlang" systems in
Linux distributions is
still R11B.

If I read http://www.erlang.org/doc/efficiency_guide/binaryhandling.html#4
correctly, you end up
copying your binary at each append in R11B. My guess is that you can
keep the fields in Heap binaries
in R12B since they tend to be small and you always keep a linear
access to the binary reference.

On the other hand, I am not the internals expert on erlangs binary handling.



More information about the erlang-questions mailing list