Hacker Timesnew | past | comments | ask | show | jobs | submitlogin
Ask HN: Which VM is the easiest to target(for a compiler)?
2 points by evnix on Oct 20, 2019 | hide | past | favorite | 8 comments
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)



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.


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?


No this is mostly for learning.


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.



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."


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


Thank you, I did not realize




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: