20

So, purely functional languages have their own class of potentials due to the clear separation between pure and impure code. I have seen several features that are somewhat simpler to implement in Haskell like Nested Data Parallelism or Stream Fusion.

My question is, what are other improvements/optimizations that are more or less unique to Haskell in terms of feasibility/simplicity but not yet implemented? (I mostly care about GHC, but also love to hear about others)

3 Answers 3

26

One optimization I'd love to see in GHC is supercompilation. That seems unlikely in the near-future of GHC, though, because it's whole-program optimization, and GHC is very focused on module-at-a-time compilation.

Basically, supercompilation is executing as much of a program as possible at compile time. It naturally subsumes inlining, deforestation, specialization, and any number of other techniques. Early experimental results have been promising, but it's a very expensive process. It's hard to see it being a practical optimization, but the concept is ridiculously awesome.

7
  • 1
    There are a few projects on this, for example Supero (community.haskell.org/~ndm/supero) though it's built on top of GHC. Basically supercompilation is an extended form of constant folding. Who cares for the compile time if it's only for optimized builds ? Jan 18, 2011 at 9:13
  • Also, see cl.cam.ac.uk/~mb566 Jan 18, 2011 at 9:35
  • also, take a look at code.google.com/p/hosc (it has web-app interface) Jan 18, 2011 at 14:14
  • 2
    @Matthiey, another issue pointed by SPJ is code size explosion (up to 30 times) Jan 18, 2011 at 14:15
  • Thanks for the comment (plus the buzzword supercompilation). I was about to create a question whether this is actually implemented, since it seems to be one of the natural strengths of a pure language - basically everything out of the IO monad could be optimized away with this.
    – David
    Sep 13, 2012 at 21:36
2

Another issue that SPJ states in his paper on modular supercompilation is combining supercompilation with unboxing. Possibilities for unboxing in supercompiled program are significantly reduced. This causes decrease in performance in comparison with unoptimized program passed through GHC strict-analyser/unboxer. See http://research.microsoft.com/en-us/um/people/simonpj/papers/supercompilation/

3
  • Thanks. That's very informative. But should this have been a comment to Carl's response?
    – Phil
    Jan 27, 2011 at 8:46
  • Yes, sorry for miscommenting, I'm new to Stackoverflow... Jan 27, 2011 at 12:42
  • 4
    Note that author ordering is usually significant. SPJ's influence on that work was undoubtedly significant, yet the first author is Max, so I'd call it "Max states" or "Max and SPJ state". I know that SPJ is far more well-known, but it's common courtesy to attribute the first author.
    – nominolo
    Jan 27, 2011 at 23:57
1

Another powerful but also "not yet ready for production use" technique is worker-wrapper transformation.

1
  • 3
    GHC certainly does do worker-wrapper transformation and has been for a very long time. It's used to exploit strictness information. Of course, W/W is a lot more general, and there may be many more ways to exploit it, but it's certainly used, if not in its full generality.
    – nominolo
    Jan 27, 2011 at 23:59

Not the answer you're looking for? Browse other questions tagged or ask your own question.