
Ask HN: Which VM is the easiest to target(for a compiler)? - evnix
I am working only a high level dynamically typed language, I learnt how to make it work as an interpreted language(most of it is written in java and the heavy lifting is done by ANTLR parser generator)<p>I have been wondering which VM would be the most easy to target?(I am very new to writing compilers) JVM, LLVM or even some web assembly interpreter (The language being similar to PHP&#x2F;Perl)
======
kbenson
In the past I would have said Parrot, but it appears to be defunct.

It _may_ be that some of the VMs that Raku (fka Perl 6) has generated might be
useful. I believe, at least as of a few years ago, they still mostly working
on NQP as the intermediate language, where NQP is a low language "like" Perl
(NQP is an acronym for Not Quite Perl) which is used to implement the higher
level language features, allowing for fairly easy porting to other VMs as long
as NQP is supported (for example, Raku was ported to Java by implementing an
NQP interpreter, which allowed the majority of the vastly more complex Raku
language to just work).

LuaJIT is also a popular choice I hear. This would have the benefit of using
Lua, which is a widely deployed and well known small language, and LuaJIT is
known to be extremely fast.

------
karmakaze
First off I suppose it's easier to pick a dynamically typed target. Is there a
particular reason it be a VM rather than just picking a language to generate
(e.g. JavaScript, PHP, Perl)? Do you have any requirements for performance or
parallelism?

~~~
evnix
No this is mostly for learning.

~~~
karmakaze
Lua/LuaJIT is worth a look. I've seen it come up a number of times for ease of
hosting/interfacing. It's a dynamically typed language but I'm not sure what
generating for it might be like.

~~~
ihnorton
Have a look at Luje:
[https://github.com/davidgiven/luje](https://github.com/davidgiven/luje)

~~~
karmakaze
That's very intriguing:

"Luje is a toy Java virtual machine written in pure Lua. It works by
translating Java bytecode into Lua on-the-fly, and then using Mike Pall's
LuaJIT to run the result."

------
gus_massa
If you remove the spaces before each sentence, the post will be much easier to
read, specially in mobile phones.

~~~
evnix
Thank you, I did not realize

