POV-Ray : Newsgroups : povray.off-topic : Haskell raving : Re: Haskell raving Server Time
15 Nov 2024 05:18:39 EST (-0500)
  Re: Haskell raving  
From: Orchid XP v7
Date: 1 Nov 2007 13:57:08
Message: <472a2184$1@news.povray.org>
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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.