HACKER Q&A
📣 evnix

Which VM is the easiest to target(for a compiler)?


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)

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/Perl)


  👤 kbenson Accepted Answer ✓
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?

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