[Haskell] ANNOUNCE: jhc 0.6.0 Haskell Compiler
sylvain.nahas at googlemail.com
Wed Mar 18 19:16:06 EDT 2009
This compiler is very promising, for the least.
Here is a small dummy Haskell program.
countdown :: Int -> IO ()
countdown 0 = putStrLn "finished"
countdown x = do
putStrLn (show x)
main = countdown 10000000
and the C program that comes to closest.
for(i=0; i<10000000; i++)
GHC is 6.10.1, gcc is 4.3.2, jhc is 0.6.0
arch is i386/Linux(Ubuntu)
$ ghc hello.hs -o hello1
$ jhc hello.hs -o hello2
$ gcc hello.c -o hello3
What about the size of the executables?
$ ls -l hello1 hello2 hello3
let strip them.
In the case of jhc, there is definitively room for some improvements.
I dare not say what I think of ghc.
Now, let run them.
$ time ./hello1 > /dev/null
$ time ./hello2 > /dev/null
$ time ./hello3 > /dev/null
Actually, times varie between runs. It tends to decrease (except for the
ghc generated binary), so I suppose it is due to OS cache effects.
Yet, I consistently observed that, according to "time", hello2 (jhc)
runs _faster_ than hello3 (gcc).
Something is wrong: how can Haskell be faster than C?
Last but not least, as well as generating fast code, jhc can make good
use of a C cross-compiler as back-end.
More information about the Haskell