|
|
Warp wrote:
> Orchid XP v7 <voi### [at] devnull> wrote:
>
>> In Haskell, a "string" is a linked-list of characters.
>
> I shudder thinking how much memory that must require...
It's fine for "small" strings. For "large" strings, it's really
sub-optimal in space and time.
This is why the "ByteString" library was developed. It can present a
string-style interface, yet every character consumes only 1 byte of
storage (plus a little overhead for the array itself).
In the most efficient variant, the string is actually a linked list of
array chunks. That means you can do fast concatinate (just link some
chunks together), fast substring extraction (just point to the ends, no
data is copied), and GC can free individual chunks of data. And yet, it
all handles "as if" it were a naive linked list of individual characters...
So you see, Haskell *can* be made efficient. It's just not completely
done yet.
Post a reply to this message
|
|