Angel \”Java\” Lopez on Blog

January 4, 2010

AjLisp family: implementing lisp interpreters in C#

Filed under: .NET, AjCoreLisp, AjLisp, AjScheme, AjSharpure, Lisp, Programming Languages — ajlopez @ 3:22 am

In the last months, I was active written Lisp interpreters. Since the eighties, I like to write such interpreters. One of my preferred exercises when I study a new programming language, is to write a Lisp interpreter.

In 2008, I published a code written in C#, AjLisp:

AjLisp: a Lisp interpreter in .NET

At mid of 2009, I started to research Clojure. Then, I decide to explore the news ideas of that language, reimplemeting it in C# (original Clojure is written in Java, but there is a version written in .NET, that compiles to .NET using Dynamic Language Runtime). It’s only an interpreter (I should study more about DLR or .NET compilation, to write down a compiler; and about how to do it… ;-). The result is work in progress, named AjSharpure (I named it AjClojure, but I had to change the name). You can see the code, under development:

http://code.google.com/p/ajlisp/source/browse/#svn/trunk/AjSharpure

Initially, my idea was to port “one-to-one” Clojure java code, but I realized that its code is not easily read, no test on code, no spefication about the behavior of dozens of methods, so I stopped, and rethinked my way. I took courage, forget my initial code, and start bottom-up, full TDD, implementing piece by piece, only trying to follow the external behavior of the language, instead of its internal implementation.

I stopped AjSharpure development, to study more about variables in Clojure, Shared Transactional Memory, and other topics. Then I back to 2008 version of AjLisp. I write a new version in 2009, with major refactoring of the previous one. Now, it can manage native objects and values. The trunk is at:

http://code.google.com/p/ajlisp/source/browse/#svn/trunk/AjLisp

There is no “plain vanilla” Lisp, and there are TWO main dialects: Common Lisp and Scheme. I don’t like Common Lisp (I should write a post about my reasons), so, in order to know more about Clojure and current Lisp development, I started AjScheme, an interpreter that implements most of the Scheme reference (I give up to implement macros as in Scheme, I back to mlambdas and alike):

http://code.google.com/p/ajlisp/source/browse/#svn/trunk/AjScheme

AjLisp was born following an old Christian Queinnec book (I didn’t find the code of that book in the web). He wrote a Lisp interpreter in Lisp itself. Queinnec use a simplified Lisp. But I want to study more about the minimal needed kernel. So, now I’m working on AjCoreLisp:

http://code.google.com/p/ajlisp/source/browse/#svn/trunk/AjCoreLisp

It has no parser or lexer. The idea is implement an minimal interpreter using AjCoreLisp as the basis: the result is named MinimaLisp, and it’s included in the trunk. I’m implementing few primitives, and I’m trying to write the rest of the common forms as functions or macros. A geeky decision: implement backspace macro expansion as a macro! See code at:

http://pastie.org/765371

Once I have AjCoreLisp stabilized, I will refactor AjLisp, AjScheme, to use a more slim kernel, but re-implementing the most used forms as primitives. I should measure the impact of using most used forms as macro. I’m confident on the successful of changes, since all is backed by a battery of test (TDD and tests save my day many times, when I refactored much of this code base).

I will write detailed posts about these different interpreters, variations over a leit motiv: the beautiful ideas of Lisp language.

Keep tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

4 Comments »

  1. [...] AjLisp family: Implementing Lisp Interpreters in C# [...]

    Pingback by AjCoreLisp and MinimaLisp, a minimal Lisp interpreter implementation « Angel “Java” Lopez on Blog — May 3, 2010 @ 9:40 am

  2. [...] AjLisp family: Implementing Lisp Interpreters in C# [...]

    Pingback by AjCoreLisp y MinimaLisp, un intérprete Lisp mínimo - Angel "Java" Lopez — May 4, 2010 @ 9:47 am

  3. [...] @ 9:07 am Last year, I met Clojure, a Lisp dialect compiled to Java. I was coding AjSharpure (see AjLisp Family: Implementing Lisp Interpreters in C#), a Clojure-like interpreter (not compiler), in .NET (if you want a more complete implementation, [...]

    Pingback by Memory transactions in AjSharp using References « Angel “Java” Lopez on Blog — June 7, 2010 @ 9:07 am

  4. [...] encontré con Clojure, un dialecto de Lisp que compila a Java. Estuve codificando AjSharpure (ver AjLisp Family: Implementing Lisp Interpreters in C#)(La familia AjLisp, implementando intérpretes Lisp en C#), un intérprete tipo Clojure (no un [...]

    Pingback by Transacciones en memoria en AjSharp usando References - Angel "Java" Lopez — June 8, 2010 @ 9:19 am


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Theme: Shocking Blue Green. Get a free blog at WordPress.com

Follow

Get every new post delivered to your Inbox.

Join 67 other followers

%d bloggers like this: