Hacker News new | comments | ask | show | jobs | submit login
Let me see your Lisp implementation. Here's mine. (github.com)
120 points by krig on Oct 24, 2011 | hide | past | web | favorite | 50 comments



It seemed appropriate to post this today. Did this while learning lisp about two years ago. Nothing special, a pretty straight forward implementation of the original LISP paper written while reading the paper, basically. It's difficult to describe the feeling when it clicks and the eval function comes together. All of the complexity of writing a language and an interpreter, reduced to what is basically one function that fits in a page. That is mind blowing.

Edit: I realised this works as a homage to Dennis Richie as well, as it's written in C. I did use glib for some support functions, other than that it's ANSI C.

R.I.P.


Warts and all: http://ww.com/ascheme.c.txt

It's not quite finished (and it's patterned after scheme rather than lisp, but that's close enough) but it runs the towers of Hanoi sucessfully. Lots of stuff still missing, tail call optimization, gc and a whole bunch of other must haves. There are likely lots of bugs too and things that don't work the way they should such as the '.

My understanding of the language is still patchy enough that it probably doesn't work in the way you expect it if you are a schemer.

One of these days I hope to do a proper job of finishing it (too much stuff to do) and do a write-up on it.

Writing this helped me tremendously in understanding the lisp family of languages.

Don't laugh too hard at the definition of >



I was thinking about pointing out that tutorial.

Until I went through it, I'd mostly just played with Haskell for Project Euler and other small problems. That tutorial really helped get the feel for larger projects in the language.

But at the same time, it shows off some of the elegance of lisp. It's simple enough that you can implement it as a beginner tutorial, but the end result is a surprisingly solid language.

One of the beauties of lisp is how much is possible just from some simple building blocks. That tutorial did an excellent job displaying it from the side of a language implementer rather than a language user.

Thanks a ton for it, it was really a pleasure to use.


Thanks a bunch for that tutorial! It demystified language implementation and taught me a little Haskell along the way. Oh and showed me the beauty of parser combinators.

(I didn't run very far with it but here's my code if anyone is curious: https://github.com/samsonjs/elschemo/blob/master/lisp.hs)


I remember seeing your tutorial before and thinking it looked like a great exercise. Do you think it would be worthwhile for someone with a moderate Haskell background who wants to learn some Scheme? Or is it best to go into it the other way round?


I think it might be quicker to read some Scheme programs to get a feel for the language. It's usually harder to understand exactly what a program is doing by looking at the source code than it is to look at the output of the program and figure out how it got there. (This is also why I always ask for demos and changelist descriptions that explain the intent of the change when I do code reviews at work.)

Some time, it might be fun to write a Haskell interpreter in Scheme. :-) There're all sorts of cool challenges involving type inference there.



Here's mine, in JavaScript: https://github.com/TikhonJelvis/js-scheme Live here: http://inst.eecs.berkeley.edu/~tikhon/scheme

I never got macros to work :( Still, the basics like lambdas do work.

The really cute bit is that it lets you include <script language="scheme"> blocks in your html and actually parses them. It even lets the scheme code access JavaScript objects using some special syntax.

There's one of those blocks in the source of the page; be sure to check it out.


Cool idea :-)

Here's mine: http://code.google.com/p/bobscheme/

Bob is a suite of implementations of the Scheme language in Python. It currently includes:

- A Scheme interpreter

- An implementation of a stack-based virtual machine called the "Bob VM"

- A compiler from Scheme to Bob VM bytecode

- A serializer and deserializer for Bob VM bytecode

- An alternative, functionally-equivalent implementation of the VM in C++ - BareVM


Mine, uh, has the distinction of being the only one implemented entirely while riding the bus: https://github.com/technomancy/bus-scheme


https://github.com/rictic/twerp-h

Tiny stackless lisp with continuations, written in Haskell.

~150 lines of interpreter, ~40 lines of parser.


https://bitbucket.org/pypy/lang-scheme/

I haven't personally worked on it per-se, but I've worked on the compiler, JIT, and GC for the language it's implemented it :)


https://github.com/manuel/edgelisp (Lisp->JavaScript compiler)

https://github.com/manuel/ell (Lisp->C compiler)

https://github.com/manuel/schampignon (Kernel interpreter in JS)


https://github.com/Scriptor/pharen (Lisp -> PHP)

It's been a while since I worked on it, but I think I might start again pretty soon.


https://github.com/rongarret/Ciel

Implemented in C++. Makes extensive use of C++ features and libraries to produce a lot of lisp in a small number of LOC. Includes exceptions, a full numeric tower (including unlimited-precision floats, courtesy of CLN), vectors and dictionaries (courtesy of the STL), and dynamic code loading (courtesy of dlopen). Uses the Boehm GC. Still buggy, not quite ready for prime time, but it does work.


Here's mine in JavaScript, done as exercise 51 of Chapter 5 of SICP: http://boshi.inimino.org/3box/inimino/projects/SICP/chap_5/E...

It's an incomplete toy level Scheme subset with bugs, but it has HTML5 canvas support and some cute features like showing you the progress of the VM instead of hanging the browser, and call/cc. I'd like to finish it someday.


Two variants of Scheme, with shared libraries:

http://github.com/jcoglan/heist http://fargo.jcoglan.com

If it weren't for Lisp it would never have been so easy for total noobs like me to get into language hacking.


https://github.com/gyepisam/perl-lisp

Initially started off as a toy implementation and eventually fleshed out into a pretty nice system, used in a production environment for several years as a DSL in a perl based system.


http://github.com/akkartik/wart

Arc-like names, python-like keyword args and indent-sensitivity.


https://gist.github.com/1311342

I started this a few weeks ago after rereading sicp chapter 4 and realizing that it made more sense this time around.

Some of the most fun I've ever had with programming (though I haven't been doing it very long). Never got around to doing the cool stuff at the end of SICP though, I should really get on that...


https://github.com/samsonjs/lake

Just a half-baked implementation of a simple Scheme in C.



Port of Peter Norvig's Lispy to CoffeScript: https://github.com/bradjasper/lispy.coffee/




Peter Norvig's lispy ported to 800 lines of C:

https://github.com/sck/clispy

There's also a new version I've been working on that's more R5RS compatible and will support compilation to x64_86:

https://github.com/sck/ponzi

RIP John ...


I've been working on a MACLISP interpreter based on 80's manual I found on my fathers bookshelf. It's quite fun working backward, and seeing how the dialect influenced modern lisp.


literally just wrote this last night and pushed it live this morning before hearing the news. I had just changed my gmail status to "season of the lisp" as I go through a seasonal fixation w/ lisp every year starting in october - when an old colleague messaged me to inform me of his passing.

https://github.com/ORDER-OF-NO/scphpeme

(CONS (QUOTE R) (LIST (QUOTE I) (QUOTE P)))


Pretty warty implementation. You have to pass strings and their lengths to a C function. Ah well, it's the intention that counts. :)

https://github.com/GrooveStomp/SnakeEyes


I was currently working through "An incremental approach to compiler construction" in Clojure, so this isn't done: https://github.com/spacemanaki/incremental-compiler

Previously, in C and to C, for the end of SICP: https://github.com/spacemanaki/lisp-in-c


Lisp implemented in Java. Fairly complete set of datatypes and functions, but no objects. Has been available for 10 years. http://jatha.sourceforge.net/


http://zwizwa.be/-/libprim/

Lisp in 3 stages: primitive data, composite data, composite functions.


Mine is in Python with several usual and some less usual influences: John McCarthy "Recursive Functions of..." by way of Paul Graham "The Roots of Lisp"; Peter Norvig "(How to Write..." and tail recursion from his "(An ((Even Better)..."; quoted-printable encoding of characters; Wikipedia & Knuth's enthusiasm for the balanced ternary number base. I have gone a very short way to start translating Lisp programs to Python code. Also I have gone a very short way to do relevant proofs in Coq in the manner of Benjamin C. Pierce, et al. "Software Foundations". My notions are to implement the Calculus of Constructions in the simplified form found in Claudio S. Coen, "Mathematical Libraries as Proof Assistant Environments", and natural deduction on top of that. And a TR SECD machine. Oh, and algorithms from Artificial Intelligence: A Modern Approach. And a pony... http://github.com/minopret/minopret-lisp


https://github.com/jsn/sillyscheme

My scheme implementation, written in C a year ago, just for fun. Took me a week or so, 942 C LoC.

From the README: "lexical scoping, Fixnum and floating point arithmetics, unhygienic macros, tail-call elimination, reentrant continuations, and automatic memory management (garbage collection)".


A Kernel interpreter in C: http://www.bitbucket.org/AndresNavarro/klisp

Just this week I got my first fork and a bunch of nice contributions.


This is mine implementation on C -> https://github.com/grouzen/fflisp I wrote it after I read original LISP 1.5 book (%.





https://github.com/antoinehersen/petitML

Lambda calculus to PPC assembly.


https://github.com/lautis/lisp-prolog/blob/master/lisp.pl

Tiny lisp written in Prolog in exchange for some course credits.



A very cheap, still in progress implementation in js :) https://github.com/pabloPXL/jils


http://github.com/wsxiaoys/carc

An implementation try introducing arc style first-class macro.


https://bitbucket.org/gr3dman/lishp

In Haskell. Has partial application, but is otherwise terrible.


If only all the toy lisps were instead patches for sbcl, abcl, ccl, clisp, clojure, racket, chicken or gambit...


Implementing a tiny Lisp is an exercise in learning to be a better programmer by teaching yourself how language implementations work. Creating a patch for someone else's Lisp interpreter is not a reasonable substitute.


I would be terrified if patches of the same quality as my toy lisp were actually applied to a project like sbcl or clojure.


Doing a toy Lisp is a really great way to figure out how to write a compiler without getting caught up in type systems and whatnot.




Applications are open for YC Summer 2019

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: