[Haskell-cafe] Reversing a string of words: C# v Perl V Ruby v
ndmitchell at gmail.com
Sun Dec 10 17:38:18 EST 2006
> However, every response to this question I've seen (admittedly only three
> or four so far) used StringBuilder. When I ask, "why not use Join?" most
> C# programmers seem to respond that StringBuilder is "faster" (I haven't
> measured the difference in performance).
I don't know, but I'd be really surprised if Join wasn't implemented
in terms of StringBuilder at worst. Possibly it does a summation of
the lengths of the String's in the list, and does exactly one
allocation, making it much more efficient. Either way, if there is a
function in the libraries, you shouldn't be able to write one which is
I suspect people saying "use StringBuilder" have read an article on a
website telling them that String concat is slow - but haven't thought
about the implications...
More information about the Haskell-Cafe