[Haskell-cafe] Is the #functional programming paradigm antithetical to efficient strings? #Haskell

Bardur Arantsson spam at scientician.net
Mon Jul 11 21:09:34 UTC 2016


On 07/11/2016 02:54 PM, David Fox wrote:
> On Sun, Jul 10, 2016 at 11:44 AM, KC <kc1956 at gmail.com
> <mailto:kc1956 at gmail.com>> wrote:
> 
>     Is the #functional programming paradigm antithetical to efficient
>     strings? #Haskell
> 
>  ​I can certainly see how it might seem so.  Our main string
> representation​ uses about 10 times more memory than seems necessary,
> and is relatively fast, though probably not compared to C.  Recently I
> spent some time looking into how to reduce this memory overhead, and I
> modified the pretty library
> (https://github.com/ddssff/pretty/tree/textdetails) so it could use any
> type that was an instance of ListLike and StringLike
> (https://github.com/JohnLato/listlike
> <https://github..com/JohnLato/listlike>).  Then I tried the UnitLargeDoc
> test with several different data types.  This just concatenates a list
> of ten million "Hello" strings.  Using String this happens in about 5
> seconds.  Using strict or lazy Text it immediately blew the stack.  When
> I increased the stack size to over 1GB it took minutes to complete. 
> When I used the Data.Text.Lazy.Builder type instead it took about 30
> seconds to complete.  Results with utf8 encoded ByteStrings were siimilar.
> 

Did you try similar code on Java/C# (or whatever)?




More information about the Haskell-Cafe mailing list