upscheme/femtolisp
Jeff Bezanson 6afa9c998f small readme fix 2012-02-17 17:42:03 -05:00
..
attic initial implementation of let-syntax 2009-03-17 21:53:55 +00:00
examples some cleanup 2012-02-17 17:38:10 -05:00
lib adding gensym?, fixing keyword? 2009-08-09 17:05:40 +00:00
tests some more renaming 2012-02-17 17:39:41 -05:00
tiny some cleanup 2012-02-17 17:38:10 -05:00
.gitignore some cleanup 2012-02-17 17:38:10 -05:00
FLOSSING fixed some small flaws in (compare) 2008-08-30 22:18:20 +00:00
LICENSE changing license, since google code does not support the CPL 2008-08-30 02:56:46 +00:00
Makefile some cleanup 2012-02-17 17:38:10 -05:00
Makefile.macosx adding dependency on equal.c in makefiles 2010-02-05 19:56:10 +00:00
README.md small readme fix 2012-02-17 17:42:03 -05:00
aliases.scm adding interoperability with boehm gc if BOEHM_GC is defined 2010-05-02 20:36:39 +00:00
ascii-mona-lisa support reading hex float literals 2008-11-23 07:12:37 +00:00
ascii-mona-lisa-2 support reading hex float literals 2008-11-23 07:12:37 +00:00
bootstrap.sh simplifying code by eliminating the hybrid stack/heap calling convention 2009-07-20 04:57:17 +00:00
builtins.c misc. updates, mostly about portability and warnings 2010-08-04 19:03:19 +00:00
compiler.lsp getting rid of label 2010-12-23 06:49:37 +00:00
cvalues.c misc. updates, mostly about portability and warnings 2010-08-04 19:03:19 +00:00
equal.c fixing a bug in character-number comparison 2011-12-14 06:57:25 +00:00
equalhash.c misc. updates, mostly about portability and warnings 2010-08-04 19:03:19 +00:00
equalhash.h adding equalhash.c 2008-11-28 21:44:59 +00:00
flisp.boot improved implementation of backquote 2011-04-11 03:24:30 +00:00
flisp.c getting rid of label 2010-12-23 06:49:37 +00:00
flisp.h fixing small exception bug 2010-08-17 02:03:11 +00:00
flmain.c some critical bug fixes 2010-05-04 18:17:55 +00:00
iostream.c porting over some improvements: now fl_applyn can handle any function 2010-05-05 05:31:46 +00:00
mkboot0.lsp changing semantics to respect lexical scope more strictly; now 2009-08-12 04:56:32 +00:00
mkboot1.lsp adding *error-stream* variable 2009-05-05 23:51:13 +00:00
opaque_type_template.c switching to scheme #t, #f, and () values 2009-01-29 01:04:23 +00:00
opcodes.h adding support for eof-object 2009-08-09 18:04:03 +00:00
print.c getting rid of label 2010-12-23 06:49:37 +00:00
read.c checking for overflow in integer literals 2011-08-16 19:59:46 +00:00
string.c misc. updates, mostly about portability and warnings 2010-08-04 19:03:19 +00:00
system.lsp improved implementation of backquote 2011-04-11 03:24:30 +00:00
table.c fully separating femtolisp into library core and main program 2010-05-02 18:17:47 +00:00
todo getting rid of label 2010-12-23 06:49:37 +00:00
todo-scrap import femtolisp source 2008-07-01 01:54:22 +00:00
types.c fixes for boehm compatibility 2010-05-03 05:07:22 +00:00

README.md

...a purely symbolic gesture...

This project began with an attempt to write the fastest lisp interpreter I could in under 1000 lines of C. It snowballed from there as I kept trying to see if I could add powerful features with minimal code. At the same time I assembled a library of some of my favorite C code (by myself and others) to use as a base for a standard library. This includes ios, a replacement for parts of C's stdio that adds more flexible features.

Before you say "oh no, another lisp", consider the following: femtolisp is about 150kb, is very self-contained, and has the following features:

  • vectors, strings, gensyms
  • backquote
  • exceptions
  • printing and reading circular/shared structure
  • all values can be printed readably
  • prettyprinting
  • hash tables
  • support for directly using C data types ala Python's ctypes
  • equal and ordered comparison predicates that work on circular structure
  • proper tail recursion
  • io and memory streams with utf8 support
  • highly compatible with Scheme, including some R6RS features
  • simple, well-organized, powerful API with as few functions as possible
  • compacting GC
  • and...

...it is fast, ranking among the fastest non-native-compiled Scheme implementations. It achieves this level of speed even though many primitives (like map) are written in the language instead of C. femtolisp uses a bytecode compiler and VM, with the compiler written in femtolisp. Bytecode is first-class, can be printed and read, and is "human readable" (the representation is a string of normal low-ASCII characters).

femtolisp is a simple, elegant Scheme dialect. It is a lisp-1 with lexical scope. The core is 12 builtin special forms and 33 builtin functions.

A primary design goal is to keep the code concise and interesting. I strive to have each concept implemented in just one place, so the system is easy to understand and modify. The result is high reliability, because there are fewer places for bugs to hide. You want a small core of generically useful features that work really well (for example, see torture.scm).

Almost everybody has their own lisp implementation. Some programmers' dogs and cats probably have their own lisp implementations as well. This is great, but too often I see people omit some of the obscure but critical features that make lisp uniquely wonderful. These include read macros like #. and backreferences, gensyms, and properly escaped symbol names. If you're going to waste everybody's time with yet another lisp, at least do it right damnit.

Another design goal is to avoid spurious novelties. Many others offering their own "shiny new" lisp dialects get carried away and change anything that strikes their fancy. These changes have no effect except incompatibility, and often make the language worse because the new design was not as carefully thought out and has not stood the test of time. For example, how does it help to remove backquote? One design changes the syntax of quote. Some systems disallow dotted lists. (I've seen all three of these.) What's the point? Implementers wave the banner of "simplicity", yet wedge in all kinds of weird implicit behaviors and extra evaluation rules.

Lately a surprising amount of FUD has been spread about tail call optimization. I agree that not every language needs it, but I would like to refute the idea that it makes interpreters slow. Look at the "tiny" subdirectory or the "interpreter" branch to see a pure s-expr interpreter with efficient TCO. All you have to do is keep track of whether you're in tail position, which can be done very cheaply. These interpreters are difficult to beat for speed, yet they have lexical scope and TCO.

This project is mostly a matter of style. Look at the code and you'll understand.

This is what I do for fun, because it is the exact opposite of the kind of thing people will pay for: an obscure implementation of a programming language everybody hates.