Erlang Efficiency quesitons

Klacke <>
Thu Mar 15 10:10:16 CET 2001

On Wed, Mar 14, 2001 at 05:45:29PM -0500, Alexander Williams wrote:
> On Wed, Mar 14, 2001 at 05:38:59PM +0000, Francesco Cesarini wrote:
> > * Use binaries when shuffling around large amounts of data between
> > processes.
> > * Some one on the list had mentioned that appending binaries results in
> > them being copied, thus avoid it.
> You know, I'm wondering why no one's suggested before (and I suppose
> I'm suggesting now) why the underlying representation of strings
> hasn't been changed to Binaries instead of Lists (or at least
> discussion thereof).  If the functions in string: were changed, that'd
> be 80% of the tweaking necessary right there.  One can already do
> pattern-matching on Binaries, so you don't lose much there.
> >From an efficency PoV, the main drawback would seem to be that
> Binaries copy when appended, but going to a different programming
> pattern that involves building lists of Binary-strings and then
> joining them should be able to get around that problem; Python's
> strings are "immutable," much as Binaries seem to be, and so share the
> quality of being copied to create a new entity when +'d, but if one
> constructs a List of strings, calling string.join() on the List will
> return a single string without much overhead.
> Thoughts?

This was one of the original goals of the bitsyntax as well, i.e. 
to be able to with ease use Binaries as an efficent replacement
for strings. I even once wrote a bstring.erl which was a module
with an equivalent interface as string.erl

This idea still holds. Possibly some explicit support for 
string management should be added to the runtime as well.

String handling has been (and still is) one of the really
weak points of Erlang. At least from a performance point
of view, strings as lists (as we have it today) are slow, but
very flexible and nice. Right !!. Probably we want both.


Claes Wikstrom                        -- Caps lock is nowhere and
Alteon WebSystems                     -- everything is under control        --

More information about the erlang-questions mailing list