
Khudyakov Alexey
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?
+1. There's a lot that can be done in this area, even without complete information (though I wouldn't mind Haskell being total and dependently typed...), if you hack around unsafePerformIO. There's a good reason the language shootout passes such things as arguments to the program, but not getting faster there doesn't mean that it doesn't make sense to aggressively compile-time evaluate... or automagically memoise, or do any of those other optimisations gcc can only dream of. On the "why"-question... lacking manpower, and, possibly, line count not having enough weight in the shootout. For now, you can just use TH to force things getting evaluated. (Try to do that in C) -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited.