Lunacy


[Formerly Known as Lumberjack]

Jul 2012 Note: many of the things I was aiming for with Lunacy were accomplished with my new language, Irken.

Lunacy distribution: lunacy-2000-07-30.tar.gz
here's a version hacked to run on a 64-bit platform (tested on amd64): lunacy64-2004-02-22.tar.gz
64-bit version for Mac OS X (g5): lunacy64-g5-osx.tar.gz
[Note: the 64-bit tarballs unfortunately are forked from the main distribution, a merge should be done soon]


Lunacy is a virtual-machine/compiler for the 'diamond-like' core of the Scheme programming language:

Lunacy will eventually support front ends for Scheme and an extended dialect of Python. It will emphasize the use of first-class continuations (i.e, call/cc will have no overhead). I intend to use it to explore sophisticated asynchronous I/O techniques for networking (like Medusa, only using coroutines), and as a powerful development environment for Win32.

I hope for Lunacy to be fast enough to delve into some areas such as fast parsing (HTML, Python, CORBA IDL, etc...), text formatting/layout, and composable user interface components (a la Fresco/Interviews/Swing).

Lunacy began life as an x86 compiler. While putting together the runtime for x86 lunacy, I found myself spending a lot of time on nasty little bootstrapping details. (The compiler itself was easy).

Now that I've taken a full-time job, I do not have the time-luxury of building a system that is completely free of C. So for now I am building a VM version of the system; this allows me to move much more rapidly. If and when the need arises for the x86 compiler, it will be there, and usable: the runtime data structures, gc, etc... are nearly identical between then two systems. It should be possible at some point to build a hybrid system that will be able to mix bytecode and native code.

The VM is very tiny; it uses a couple of GCC extensions (lexical and inline functions) that let me put put the entire VM into one function, without having to use a lot of macros. [note: this is largely unnecessary, I can achieve much the same effect using globals and inlining.] How small? A tarball of the stripped VM and runtime image is currently weighing in at a 24KB. You could hide it in a banner ad GIF.

If the system becomes popular, then the same pressures brought to bear on the current Python implementation will motivate hackers to improve Lunacy. And there will be lots of room for improvement. Because of its grounding in Scheme, most modern compiler technology will be applicable.


The garbage collector is a simple two-space Cheney copying collector (< 200 lines of C). Somewhere down the line this will probably grow up and become a generational collector. 'generational gc' uses multiple heaps, and collects only one of them very often.

Lunacy is a continuation-based compiler. The following books are my main references:


Lunacy will most likely be released using a Python-style copyright ('do what thou wilt'), though I may consider looking into Ghostscript-style multiple licenses.

A Quick Tour of the Compilation Process

If you have any questions, or would like to help out, drop me a line!

Status

-Sam
rushing@nightmare.com