Sunday, March 18, 2012

V8 and Lua

I haven't posted in a long time. I have been investing a lot of time into the nosql database I was working on. The biggest change their lately has been integrating v8 and lua into the code base. One of the things I really liked about integration of Lua was something called Lunar. It is an incredibly easy way to simplify Lua integration in c++. I don't remember all of the changes I have made to my version over years: stuff like meta method support, etc. If you are trying to do some Lua integration, it is a great place to start.

But in order to get some friends to help me work on Logjammin', I had to start incorporating v8 (silly JS developers). I have to say that I found certain parts of the v8 documentation and examples really hard to follow. After spending an entire afternoon just trying to get a print function into logjamd, I realized that it would be pretty straightforward to create a v8 version of Lunar. It is actually slightly easier because of the cached template objects that normally get used. And because I am currently reading Quicksilver by Neil Stephenson, I decided to call the helper file "Jesuit". To be honest, I was thinking of Janissaries, since that is how book two ends. But that was too long of a word.

Anyway. The Lua version is here:

And the v8 version is here: