[Haskell-cafe] Re: String vs ByteString

John Millikin jmillikin at gmail.com
Sun Aug 15 01:32:51 EDT 2010


On Sat, Aug 14, 2010 at 22:07, Donn Cave <donn at avvanta.com> wrote:
> Am I confused about this?  It's why I can't see Text ever being
> simply the obvious choice.  [Char] will continue to be the obvious
> choice if you want a functional data type that supports pattern
> matching etc.  ByteString will continue to be the obvious choice
> for big data loads.  We'll have a three way choice between programming
> elegance, correctness and efficiency.  If Haskell were more than
> just a research language, this might be its most prominent open
> sore, don't you think?

I don't see why [Char] is "obvious" -- you'd never use [Word8] for
storing binary data, right? [Char] is popular because it's the default
type for string literals, and due to simple inertia, but when there's
a type based on packed arrays there's no reason to use the list
representation.

Also, despite the name, ByteString and Text are for separate purposes.
ByteString is an efficient [Word8], Text is an efficient [Char] -- use
ByteString for binary data, and Text for...text. Most mature languages
have both types, though the choice of UTF-16 for Text is unusual.


More information about the Haskell-Cafe mailing list