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

Bardur Arantsson spam at scientician.net
Mon Jul 11 22:33:41 UTC 2016


On 07/12/2016 12:22 AM, David Fox wrote:
> 
> 
> On Mon, Jul 11, 2016 at 2:09 PM, Bardur Arantsson <spam at scientician.net
> <mailto:spam at scientician.net>> wrote:
> 
>     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>
>     > <mailto: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)?
> 
> 
> ​I did not.​
>  

Do try it -- it's an educational experience! (Even in C++, Rust or
whatever takes your fancy.)

(... and at this point I'm left wondering whether KC is just trolling.)



More information about the Haskell-Cafe mailing list