Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Haskell:

http://www.haskell.org/pipermail/haskell-cafe/2009-August/06...

Twice as slow as C but without also in-place like C and extremely similar (see the sort function here):

http://en.wikibooks.org/wiki/Algorithm_Implementation/Sortin...

It's interesting to see is how very similar Haskel and C sources fundamentally become once they really solve the same problem and not the different ones.



The "direct compare" in Haskell isn't. The Ord constraint effectively passes a dictionary, and even if that were inlined in a particular case you could always apply a newtype for a different ordering.


I'd really like to learn, can you please explain where the Ord constraint is, and where the dictionary is passed in the link I've given (with the STUArray -- isn't that really an array in a C sense)? To give you an idea how little I know: I understand the basic ideas of Haskell (that is, what I as a C programmer who made some compilers understand as basic: the type inference and the illusion of the infinite memory by not doing things in place but lazily with the GC unless unsafe or when it is possible to optimize the laziness out) but I don't really know the language. Thanks in advance.


Ah, my bad, the STUArray example is specialized and probably does not pass an Ord around (though there's implicitly one present because of the less-then). Certainly, the function does not meaningfully allow the user to pick it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: