Hacker News new | ask | show | jobs
by fusiongyro 4916 days ago
Only one of the Haskell shootout programs uses `unsafePerformIO` now (n-body). While it looks to me like most of them make fairly heavy use of Foreign and thus low-level types, I don't think this automatically makes Haskell code like messy C code. After all, there still isn't pointer arithmetic, types don't magically transform into other types behind the scenes, and there's still a fair degree of non-strictness. More importantly (and contrary to C's "messiness") it's seldom difficult to take Haskell optimized with these low-level features and wrap it up in a nice high-level package for use from elsewhere. It's a curious and wonderful property of GHC that you can enable all the extensions you want on a module-by-module basis without creating a lot of cross-module drama. These are properties other languages should strive for.

Writing exceptional, highly performant Haskell is still a black art, sure. But writing performant Haskell is basically writing Haskell with a modicum of knowledge and respect (less lazy IO, more ByteString, more iteratees, etc). Writing highly performant Haskell is becoming easier and easier; the runtime system will give you detailed statistics about where your problems may lie, tools like ThreadScope can give you all the information you'd ever want, and many of the commonly-used libraries are heavily optimized for speed (Text, ByteString, iteratees, etc) which you benefit from basically for free.

It's not a panacea but I haven't ever had to use anything more sophisticated than strictness annotations, and even that I use pretty sparingly. Like the best black arts, it's very seldom necessary, and becoming more seldom every day.

As a side note, I would love to see an alternative "honest" shootout where programs must not do much overt "doping" (such as using Foreign and `unsafePerformIO`) because it would be interesting to compare the "native" speeds of different languages, with the kind of code the best normal people would write for themselves or their employer. Haskell has always abused its low-level facilities for higher placement in the shootout than it really deserves.