I think that a higuer level language has better opportunities to optimize, specially if the compiler is coded in its own language. for example I guess that a good type dependent implementation would evaluate the sum[1..10^9::Int] at compilation time. I reality haskell is much much faster than c in some cases that now are not considered, but it is fair to remember that haskell outperfromed all the rest in those old benchmarks with did´t care to print the results. This may seem trivial now, but at the time surprised the benchmark people. 2009/2/21 Khudyakov Alexey <alexey.skladnoy@gmail.com> On Friday 20 February 2009 16:29:29 Bulat Ziganshin wrote:
Hello haskell-cafe,
since there are no objective tests comparing ghc to gcc, i made my own one. these are 3 programs, calculating sum in c++ and haskell:
main = print $ sum[1..10^9::Int]
... skipped ...
The discussion is mostly about low level optimizations such as loop unrolling etc.
I have another question. Why shouldn't compiler realize that `sum [1..10^9]' is constant and thus evaluate it at compile time?
-- Khudakov Alexey _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe