3 ms·
By break0, it looks like we're just writing Haskell-ified C. (Lots of ugly, similar safety guarantees.)
by awda 13y ago
By break0, it looks like we're just writing Haskell-ified C. (Lots of ugly, similar safety guarantees.)
- thirsteh 13y agoIndeed. Many of the high-performance libraries like bytestring, aeson, etc. are written like this. Haskell's performance is very good for nearly everything I write--and I don't write anything nearly that low level--but I can't deny that this is one of the uglier sides of the language. On the other hand: In most other languages you'd just be dropping down to the C ABI (that's easy to do in Haskell, too, for that matter.) It is kind of impressive that you can write code that is as fast as C without writing C, even if it is ugly.
- 1amzave 13y ago> It is kind of impressive that you can write code that is as fast as C without writing C, even if it is ugly. Impressive, perhaps -- but from a maintainability perspective I think I might prefer to pay the cost of jumping the language barrier to be able to write natural, comprehensible C rather than staying within one language and dealing with an unreadable jumble, even if it performs as well.
- thu 13y agoThe final Haskell code, while being low-level, is not unreadable jumble. Maybe you're talking about the generated Core or the C-- code.
- nightski 13y agoI disagree wholeheartedly on the similar safety guarantees part, Haskell still provides you with a significant amount over C in this case. But it does "look" more like it, if that means anything.
- chongli 13y agoThe difference is that with Haskell you can wrap a nice, clean, type-safe interface around all that ugly optimization. With C, you're still dealing with casts, null pointer checks, array bounds checks and all sorts of other tedious bug sources that Haskell users don't have to deal with -- unless there's a library bug, of course.