Calendar

July 2017
Mo Tu We Th Fr Sa Su
<< >>
12
3456789
10111213141516
17181920212223
24252627282930
31

Langs

MotionScript Virtual Machine

Posted on Jan 11 2005

A little more than one year ago, I was working on the Honsen project (right now freeze due to lack of time). The goal was to make a Flash-with-3D styled IE plugin so we needed a simple dynamically typed programming language. I designed the language "MotionScript" and wrote the compiler using OCaml. The compiler was generating some efficient bytecode for the MotionScript Virtual Machine, with a memory model similar to OCaml (as well as 31bits fast integers) and was using the Hans Boehm Garbage Collector. It worked great, outperforming Python by a factor of more than 2 (and ActionScript by a factor of more than 25 !).

In last October when I started looking again at web languages (PHP and the likes) in order to choose a language for the upcoming Dinoparc.com website, I was quite stressed not to be able to find a high-level language with a good type system. Since Motion-Types was already working, I slightly modified the AS code generator to get a MotionScript generator (since syntax is 90% the same) so I can run Motion-Types on the VM. Then I put the VM inside a mod for Apache 1.3 webserver and added APIs in order to access CGI, MySQL, and some serialization for session objects. It was done quite fast and is now working very well on both Windows and Linux.

It's not a PHP killer since it can't be embedded directly into webpages and since Motion-Types have a high learning curve, but have several interesting features. In particular all the classes are compiled into a single bytecode file that is then deployed on the server (so you don't put any sources on the server). The VM is loading the bytecode into memory with caching in order to reload it only if it hasn't been modified. This way all statics (regexp, templates parsing, xml, mysql connection...) are initialized one time at loading and then when a page is requested the application entry point is called. Suit well with Apache 1.3 which use prefork instead of threads, but with entry point disabled it might work as well on Apache 2.0.

0 comment
Name : Email : Website : Message :