Thursday, October 13, 2005

The Story of a Virtual Machine and Common Lisp.

I've been recently proselytized into the wonderful world of common lisp (actually its been 16 months since I started out with cons, car and cdr), And infact ever since I've started out with common lisp, anything else seems incredibily constraining and suddenly I hit the brick wall.

My first peeve with CL was the lack of standard libraries for all my needs but that was just me not doing my homework. Not only does it have good bindings for most of the things I do in the form of CLOCC, but also certain nice implementations of common libraries for regular expressions , Tk bindings, etc. among other thing. My second peeve was that lack of a good IDE, but that was me again not doing my homework again and I had to shut up after seeing SLIME. So with everything that I need for all my development needs most of my hobby hacking if any has been exclusively with CL and to certain extent with scheme. (Dr.Scheme just made me skip all these 'homework' steps anyway).

But 8 years of programming C doesn't leave you that easy. I still love C for what it is - an incredibily flexible low level programming language, put in simple words 'a portable assembler', and no thats actually a compliment. The amount of control over the code you get with C is just an aderanline rush, but of a different kind. I enjoy programing in C and I'm infact so used to C that it is basically a second language to me (more so than english at times!). But I have decided to be pragmatic and realised the move to Common Lisp (when I discovered it ) was impending, but I never did expect it to come this soon.

Well, so what does all this LtU style rant have to do with the title of the post? Well thats because its the quintessential fact of life in Engineering in Tamil nadu, called the 'Final Year Project', In which all students have to develop 'something' . So my choice was a simple virtual machine for dynamically typed languages like Lisp, scheme, python etc.. But with more things like tail call optimisation, continuations, lexical closures, garbage collection - basically the works! And as a long time C programmer, my instincts were to use C for both the VM and the compiler (for a scheme like language, I would call it r4.9rs, because I find (eqv? () #f) very comforting). But since the free ride I get with using Lisp's (read) made me decide to go for the compiler in Common Lisp.

But I was very clear in the start to do the VM in C (or C++), but when I realised that I could have potential gains in using a C/C++ garbage collector for all of my book keeping code I decided to give Lisp a second chance here, but initially I was not convinced. But the interesting and helpful responses I got over at comp.lang.lisp for my post was more than enough to get me convinced that Lisp was infact a very good choice for doing so. But what acutally tipped me over the wall to common lisp was Pascal Costanza's CL implementation of a java virtual machine (big thanks there for making it MIT/BSD style open source licence).

So, what does all this mean? I will have probably have a nice Virtual machine and a compiler (for probably a scheme like language) all written from scratch in Common Lisp (I might use a bit of C here to fill in the gaps, but I guess primarily it will be in Lisp) and have lots of fun doing so. Also, I would like to mention along with this post about my partner in this project 'Venky a.k.a Intercodes', who has started blogging with a bang, some one (or the only person) who would score more than me on the average crankiness scale for normal human beings.

Hmm... Now the real question is not about the project anymore, just about our 'eminent' research scholars!

Signing Off,
Vishnu Vyas.

No comments: