While talking with Manuel AristarÃ¡n last night, I explained to him the coolness factor of mod_tora, what could be the analog of mod_rails (Phusion Passenger) for Neko, but without the nasty
So after eating pizza, we decided to hack something to convert Ruby code to basic Neko language, just for the sake of testing.
Is not only cool that this complete VM was created and maintained by one guy, but it’s even cooler that they package binaries for most important platforms: Linux, OSX, and of course, Windows.
We downloaded the packages, setup the
LD_LIBRARY_PATH and start playing with Neko compiler (
nekoc) reading the docs at the same time.
AST of Ruby
The question was, how to generate the Abstract Syntax Tree of a Ruby program?. That was easy: ParseTree
After digging a bit into the documentation, we found that inheriting from
SexpProcessor opens you the door of heaven and unleash the power of ParseTree. We followed Ruby2Ruby implementation just to get started.
Something to test
What to test? I wondered how cool will perform my sudoku solver script after going through this converter, but after looking at the Sexp it generates, realized that will take more than a couple of hours of hacking
Going back to basics, we decided to start with a Fibonacci function instead and from there move forward.
So we started with the Ruby code and added the required
tokens indicated in the sexp to successfully build the code shown below.
You can find the Neko SexpProcessor on github, under nekro project we started.
Well, I know is just plain silly do a performance comparison between a VM like Ruby with one that couldn’t compare or match all the functionality, but bear with me for a second
|platform||interpreter||version||fib(30) avg sec.|
Get your own conclusions, I’m just playing and experimenting… Thanks Manuel for your time!. I’m going now to the airport, one more flight to catch!