[Haskell-cafe] OCaml list sees abysmal Language Shootout results

Georg Martius mai99dgf at studserv.uni-leipzig.de
Thu Sep 30 16:24:24 EDT 2004


Hi folks,

On Thu, 30 Sep 2004 01:02:54 +0100, Sam Mason <mason at f2s.com> wrote:

> Greg Buchholz wrote:
>> The algorithm isn't correct (it counts spaces instead of words), but
>> anyone have advice for improving its performance?
>
> You probably want some strictness annotations in there. . .
<snip>

Last night as I have tried to improve Gregs wc in a simple fashion and came up with the same idea to make a new data type with strict fields. I thought why one couldn't add some kind of strictness annotation to the function type. First attempt:

wc :: !(Int,Int,Int) -> Char -> (Int, Int, Int)

As far as I know the compiler does strictness analysis to find strict arguments in a function anyway. Would it make sense to allow this kind of explicit strictness? Where are the problems with that?

I mean lazyness is really useful and it is our best friend in this kind of application, since we can make stream processing without implementing a buffer and so on. On the other hand one gets occasionally traped by it and it is not allways easy to grasp why.

Some more general comment: The code for the shootout doesn't need to be extremly fast in my eyes, it needs to be elegant and reasonable at performance and memory consuptions (In this order). I don't want to say that Thomaszs solution is bad, but it is not a typical Haskell style application. If someone (not haskeller) looks at the implementation it should be very obvious and clear.
The last few weeks the list have been full of performance questions (including my own ones) and it is really a pitty that it is such an issue. I believe that most problems occuring with performance and memory consumptions could be easily solved by partial and explicit strictness. Please enlight me if I am wrong.

Regards,
  Georg


More information about the Haskell-Cafe mailing list