

GHC's new cutting-edge dataflow-based code generator - dons
http://hackage.haskell.org/trac/ghc/blog/newcg-update

======
jeffdavis
I just wanted to say that it's refreshing that I can write high level code and
I can expect it to be _fast_.

I am just learning haskell, but I like the fact that I can return very large
structures (even infinitely large) and then operate on those structures much
later, and it magically pipelines everything behind the scenes.

~~~
cwzwarich
But could you really determine whether things would be efficiently pipelined
if I gave you arbitrary Haskell code examples? Magic that sometimes works and
sometimes doesn't is fun for small projects, but on a large project you really
want predictable tools. You shouldn't need knowledge of the internals of the
compiler in order to write efficient code.

~~~
dons
On a large project you optimize the hotspots using an excellent profiler...

~~~
cwzwarich
You also want reasonable and understandable default behavior so you can avoid
problems before they even occur.

~~~
fusiongyro
Different languages make different tradeoffs.

------
Locke1689
Is there any good documentation for the GHC architecture for someone who is
relatively familiar with modern (ML) compiler architecture theory, but not
practice? Or should I just start reading the cited papers for STG and the rest
of the GHC design?

~~~
ehamberg
Volume II of “The Architecture of Open Source Applications” has a good
introduction to GHC's architecture:

<http://www.aosabook.org/en/ghc.html>

~~~
mahmud
beautiful :-) didn't know there was a volume 2.

------
wonderzombie
I'm familiar with Haskell but that's about all the context I have. Anyone care
to translate, summarize, or contextualize?

~~~
dons
GHC currently has an excellent semi-whole program optimizer for Haskell-level
code. And it has LLVM for optimizing the generated assembly. What is missing
is an intermediate level optimizer that optimizes asm prior to LLVM, and has
awareness of the properties of the Haskell runtime: e.g. immutability, lack of
aliasing (properties LLVM can't see). With this last piece, all aspects of
code generation are getting heavy duty optimizer treatment.

The new code gen is also pluggable, so you can add new optimizer passes easily
(e.g. by implementing text book algorithms)

~~~
tikhonj
Heh, 'semi-whole' seems to be a bit of an oxymoron. Could you explain exactly
what that means? Do you just mean that it looks at your whole program but not
the libraries you use?

~~~
batterseapower
Basically, it inlines across module boundaries (except where such modules are
mutually recursive).

~~~
Locke1689
I don't think cyclic imports are allowed in Haskell.

~~~
dons
Sure they are, and full cross-module inlining too

~~~
tinco
Since when? I just merged 3 files together because GHC complained of the
cyclic imports. I would love to pull them apart again.

~~~
walrus
[http://www.haskell.org/haskellwiki/Mutually_recursive_module...](http://www.haskell.org/haskellwiki/Mutually_recursive_modules#GHC)

