Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a good VM for developing a hobby language?

I'm thinking about writing my own little language.

I found a few options, but feel free to suggest more.

  • JVM
  • Parrot
  • OSA

A lot of languages are using the JVM, but unless you write a Java-ish language, all the power the stdlib gives you is going to feel ugly; It's not very good at dynamic stuff either.

Parrot seems a good VM for developing languages, but it has a little abandoned/unfinished/hobby project smell to it.

OSA is what powers Applescript, not a particularly well known VM, but I use Mac, and it offers good system integration.

CLR+Mac doesn't seem a good combination...

My language is going to be an object orientated functional concurrent dataflow language with strong typing and a mix of Python and Lisp syntax. Sounds good, eh?

[edit]
I accepted Python for now, but I'd like to hear more about OSA and Parrot.

like image 249
Pepijn Avatar asked Jan 30 '10 10:01

Pepijn


1 Answers

One approach I've played with is to use the Python ast module to build an abstract syntax tree representing the code to run. The Python compile function can compile an AST into Python bytecode, which exec can then run. This is a bit higher level than directly generating bytecode, but you will have to deal with some quirks of the Python language (for example, the fundamental difference between statements and expressions).

In doing this I've also written a "deparse" module that attempts to convert an AST back to equivalent Python source code, just for debugging. You can find code in the psil repository if you're interested.

like image 182
Greg Hewgill Avatar answered Sep 23 '22 23:09

Greg Hewgill