JLisp51 (Lisp51 in Java)


My thanks to Robert Haas, who authored the original source for Lisp51 in C++, Sean Lyndersay, who actually thought this was a worthy project (most of the time, anyway), Alyssa Glass, who gave me the book that inspired me to my next project: Java 0.51 in JLisp51, and to my CS51 sections over the years, who showed me that everyone would love Lisp if only given a chance.

-- Ken Liu ()

What Is This?

JLisp51 is a toy Lisp interpreter written in Java. It can be run as an applet or a stand-alone application. The name is based on "Lisp51," which is a toy Lisp interpreter written in C++ and used for many years as a teaching project in CS51, the second intro computer science class at Harvard. JLisp51 takes some of its design ideas from Lisp51 but is not a port.

Because at one point it was thought that JLisp51 might be used to replace Lisp51, the class names and other identifiers simply used the "Lisp51" namespace. The "J" prefix was added only as an afterthought, and that explains some of the inconsistencies in the names you'll see on this page (e.g., the main class name and the command used to run the program).

Download or Run JLisp51 Over the Web

Ready to give JLisp51 a spin?  Click here.

Or shift-click here to download the jar file and also the initialization file. Make sure the jar file and the initialization files are in the same directory!

you can then run it with the command:

java -classpath Lisp51.jar Lisp51

Source

The source to JLisp51 is available free of charge upon request. Please me with a short explanation of what you'd like to do with it.

Change History

Places Using JLisp51:

If you are using JLisp51 for a class or you've put it up on your own Java programming page, please write to me with the link and I'll link to your page from here.

Supported Functions:

Currently, the following functions are available:

Functions Implemented as Java Primitives

Functions Implemented in Lisp

>
<
*
+
-
/=
=
ABS
AND
APPEND
APPLY
AREF
ARRAY-DIMENSIONS
ARRAYP
ATOM
BACKQUOTE
BOUNDP
BUILTINP
CAR
CDR
COMMA
COMMA-AT
COND
CONS
CONSP
COPY-LIST
DEFMACRO
DEFUN
DO                            
EQ
EQL
EQUAL
ERROR
EVAL
FIXNUMP
FUNCALL
FUNCTION
GET
IF
LENGTH
LET
LET*
LIST
MACROEXPAND-1
MAKE-ARRAY
MAPCAR
MEMBER
NTH
NTH-CDR
OR
PRINT
PROGN
QUOTE
REM
RPLACA
RPLACD
SET
SETQ
STRINGP
SYMBOLP
TRUNCATE           
		
>=
<=
1+
1-
ASSOC
CAAR CADR ... (up to 3 A's and D's)
EVENP
EVERY
SOME
EXP
FILTER
LABELS
LAST
LISTP
MAPCAN
MAPLIST
NCONC
NUMBERP
REDUCE
REMOVE
NOT
NULL
ODDP
PUSH
POP
REVERSE
SETF
SORT
SQUARE                
		

Supported Platforms:

Currently, the only way to run this as an applet is to use the latest version (1.4) of the Sun Java plug-in (It's better to download the jar file and run it outside the browser anyway). Since JLisp51 uses a fairly old and stable subset of features in the Java platform, as of 2007, I believe it should work on most modern browsers with up-to-date Java plugins. I still find that you get better performance -- not that it will be blazing since the code is unoptimized Java -- by running it outside the browser.

Differences Between Lisp51 (in C++) and JLisp51 (in Java)

JLisp51 can be run both as an applet and a standalone application.  Currently there is no difference in functionality between the two versions although plans are under way to add true file I/O to the application version so that you can save and load lisp files at will.

JLisp51 makes many relatively small-scale improvements over Lisp51 such as support for the BACKQUOTE-COMMA-COMMA-AT mechanism to simplify the process of writing macros, a LET* construct, a DO-loop, and a few bug fixes.

JLisp51 supports the String and Array datatypes in addition to the Cons, Symbol, Fixnum, and Builtin types supported by Lisp51.  

JLisp51's garbage collection mechanism is more interesting from a pedagogical point of view but less crucial to the correct functioning of the system as Java is already garbage-collected.  In JLisp51, the garbage collector runs as a low-priority thread on its own, although when system resources are low, the garbage collector will be explicitly invoked by the main thread (users may also invoke the garbage collector if they so desire). 

JLisp51 has a very different object hierarchy from Lisp51.  Details on its design are forthcoming.