Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What prevents an efficient Haskell virtual machine (like JVM)?

I have been wondering, what prevents the development of an efficient virtual machine like JVM or PyPy for Haskell (except maybe development effort)? Is it the language structure? I think languages, that are harder to interpret efficiently (like Python, being very dynamic), already have decent VMs.

Also, if nothing is obstructing such an implementation, would STG be a good target "bytecode", since all optimizations are done on Core?

Are there any articles or blog posts that discuss this topic?

EDITs:

  • I am aware of HaLVM, but I don't think it is what I mean.
  • I am also aware of runhaskell, but it is not efficient at all.
like image 927
aelguindy Avatar asked Feb 19 '12 20:02

aelguindy


People also ask

Does Haskell use a VM?

Nothing stops Haskell from having a VM. Haskell works beautifully on the JVM and can be even faster than GHC after JIT warmup in cases where the generated code hits the sweet spot of the JIT compiler.

What is the exact advantage of programming languages built on top of a virtual machine?

An advantage of VM is that, it is much easier to modify some parts of the code on runtime, which is called Reflection. It brings some elegance capabilities.


2 Answers

What prevents an efficient Haskell virtual machine?

Nothing - there already has been one, Daan Leijen's LVM. It was efficient enough to be used for the runtime system of Helium (the Haskell "teaching language" from Utrecht University).

That said I don't know if it is used these days, so the question "What prevents an efficient Haskell virtual machine?" could be answered as manpower, continuous investment, etc. When Haskell already has a good compiler, a good VM is a luxury as Paulo Pinto noted already.

like image 75
stephen tetley Avatar answered Oct 15 '22 08:10

stephen tetley


I am not aware of any technical restriction applying here. There is a language called Frege, semanticaly close to Haskell, that targets JVM. So it is just that nobody has considered so far that a Haskell-to-JVM compiler was worth the effort. Indeed, as a JVM-skeptic, I wonder what that would bring. If it is just intermediate language portability, I'd rather work on LLVM or on a pre-built binary farm.

like image 36
Paul R Avatar answered Oct 15 '22 06:10

Paul R