[Haskell-beginners] When to use ByteString rather than [Char] ...
menchauser at gmail.com
Sun Apr 11 08:11:08 EDT 2010
Because "String" is represented by the "[Char]", each element of String is
allocated individually. ByteString represents a string in a single array and
hasn't overhead for allocating each char.
I recommend you to read the "Real World Haskell" -
http://book.realworldhaskell.org/read/. There is some notes about
String/ByteString in the Chapter 8 -
On Sun, Apr 11, 2010 at 3:07 PM, James Fisher <jameshfisher at gmail.com>wrote:
> After working through a few Haskell tutorials, I've come across numerous
> recommendations to use the Data.ByteString library rather than standard
> [Char], for reasons of "performance". I'm having trouble swallowing this --
> presumably the standard String is default for good reasons. Nothing has
> answered this question: in what case is it better to use [Char]?
> Could anyone point me to a good resource showing the differences between
> how [Char] and ByteString are implemented, and giving good a heuristic for
> me to decide which is better in any one case?
> James Fisher
> Beginners mailing list
> Beginners at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Beginners