http://www.haskell.org/pipermail/haskell-cafe/2009-June/063454.html
Cheers,
/Nick
Don't get me wrong, it'd be awesome to have good Haskell on JVM, but
I'm fairly sceptical whether it can be done. I'd be delighted to be
proven wrong, though.
Attila.
Support for Jaskell is built-in to IFCX Wings (along with OCaml, Python,
Scheme, Ruby, Groovy, ...)!
<http://ifcx.org/attach/Wings/WingsExample.html#0.4.4.Jaskell|outline>
http://ifcx.org/wiki/Wings.html
Jim
Basically, the strict laziness of Haskell is not possible to
seamlessly marry with JVM's stack based call-and-return execution
model (at least I'm not smart enough to see how). Necessary tricks
with continuation-like constructs ("interface Code { Code exec() }")
all make the implementations very involved and hard to maintain, and
proliferation of heap-allocated thunks doesn't help performance either.
Writing an interpreter for Haskell would be no big deal, but it has
the performance you'd expect. Writing an efficient compiler, either to
bytecode or native machine code is an entirely different matter. If
you take a look at how Glasgow Haskell Compiler implements all of
this, you'll see that it emits C code that does *not* actually work as
expected with regard to strict lazy evaluation, runs it through a C
compiler, then after the C compilation step it will transform the
compiled object code, mostly putting jump sites in places of function
returns and finally link the doctored object code into an executable.
Now, you can do that with unmanaged machine code. Clearly, you can't
do that with the managed runtime environment of the JVM. (Nor with
CLR, for that matter. Given how both Erik Meijer and Simon Peyton-
Jones are Microsoft employees, if it were possible, I have no doubts
they would have since made it happen.) And the MLVM innovations don't
point in these directions either - well, continuations or at least
generators could help, I think.
Again, I don't claim these problems are unsurmountable, I'm just
saying I don't see how to solve them in a manner that is both
efficient and elegant. I'd be delighted to see someone smarter than me
overcome these problems for having an *efficient* Haskell on the JVM
implemented *elegantly*. That'd really rock.
Attila.
How does CAL handle these problems?
http://en.wikipedia.org/wiki/Quark_Framework#The_CAL_Language
See also PDFs linked at bottom of WP entry, in particular "CAL for
Haskell Programmers".
Regards
Patrick
> I'd be delighted to see someone smarter than me
> overcome these problems for having an *efficient* Haskell on the JVM
> implemented *elegantly*. That'd really rock.
That might be too much to ask, given that GHC is an efficient but
highly inelegant (per your description) implementation of Haskell on
the C VM. :-)
Microsoft Research put a huge amount of effort into trying to reconcile
Haskell and .NET in their Haskell.NET project. Note that they were not just
trying to implement Haskell on .NET but were actually changing the VM to
suite Haskell and they were still unable to create something usable. However,
their work culminated in the early adoption of some features that have become
critically important today, most notably tail call elimination.
Don Syme described in an interview with Sadek Drobi some of the lessons he
learned from their work on Haskell.NET:
http://www.infoq.com/interviews/F-Sharp-Don-Syme
--
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?e
> And the MLVM innovations don't
> point in these directions either - well, continuations or at least
> generators could help, I think.
MLVM has Lukas Stadler's nice prototype of scoped continuations, which
provides one set of useful tricks, generally of the form "expect to
run in strict mode for a while, and then take a hit as you swap part
of the control stack to the heap".
There's also Arnold Schwaighofer's tailcall prototype on MLVM, which
if crossed with invokedynamic would produce the equivalent of
patchable jump sites.
(But, did I mention they are prototypes? Sadly, JDK 7 will not
include either, since it is focusing on invokedynamic and method
handles.)
-- John
Don Syme described in an interview with Sadek Drobi some of the lessons he
learned from their work on Haskell.NET:
http://www.infoq.com/interviews/F-Sharp-Don-Syme