
About a year ago, Jeroen Leeuwenstein and I worked on CLR backend for the Utrecht Haskell Compiler (UHC) [1]. That was a one-month project for a seminar at Utrecht University, and the backend is far from being complete. But we did make some interesting observations. A particular caveat of the UHC is that it does whole program analysis, so we had access to the entire program and all libraries at compile time. A benefit of using the CLR was that it does support tail calls. So a mutual recursive function definition can loop a million times without creating a stack overflow. Our main problem (in efficiency) was lazy evaluation, not knowing the difference between an evaluated `int` and a possible thunk `Lazy<int>`. That meant we had to wrap _everything_ in a layer of indirection, e.g.:
add :: Int -> Int -> Int add x y = x + y
add 2 4
Becomes something equivalent to:
public int add(Lazy<int> x, Lazy<int> y) { return x.Force() + y.Force(); }
add(new Lazy(() => 2), new Lazy(() => 4));
Having a strictness analyser would have helped tremendously.
Also, I wonder if there is some efficient way of implementing the Lazy
class, perhaps by having the Force method using runtime code
generation to override itself. I don't know if this is possible, but I
vaguely remember the Dynamic Language Runtime on .NET doing something
like that.
I find this an interesting topic, so when you do have something more,
please let us know on this list.
- Tom Lokhorst
[1]: http://tom.lokhorst.eu/ehc/clr/ehc-clr-handout.pdf
On Tue, Feb 9, 2010 at 1:42 AM, Tony Morris
I have hypothesised a pure, lazy language on the JVM and perhaps the .NET CLR with FFI to .NET/Java libraries. I foresee various problems but none that are catastrophic; just often requiring a compromises, sometimes very unattractive compromises. I have authored several libraries in the same vain as pure, lazy programming to run on the JVM in Java and Scala programming languages.
I expect others have forethought and perhaps even experimented with such a language. Are there any dangers to be wary of that undo the entire endeavour?
Thanks for any insights.
-- Tony Morris http://tmorris.net/
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe