News for hackers. Stuff that matters.
Re:Bone Lisp – Lisp Without Garbage Collection by hkjgkjy on Tuesday June 07, 2016 @07:54AM (#11853796)
Since ulisp (lisp for Arduino) came up on HN the other day, I've been trying to implement a lisp in C with garbage collection that will run on my x86 machine (your usual macbook).

It being my first ever "real" c program, I'm not quite there yet. Very curious to read more source code of small languages, preferably things that are implemented in one file only.

Re:Bone Lisp – Lisp Without Garbage Collection by munificent on Tuesday June 07, 2016 @01:42PM (#11856144)
If you just want a GC, here's a tiny one I wrote:

https://github.com/munificent/mark-sweep

And an article I wrote about it:

http://journal.stuffwithstuff.com/2013/12/08/babys-first-gar...

This was the inspiration for uLisp's GC (http://www.ulisp.com/show?1AWG). :)

If you want a more full-featured but still small language in C, you could take a look at Wren:

http://wren.io/

https://github.com/munificent/wren

Re:Bone Lisp – Lisp Without Garbage Collection by hkjgkjy on Tuesday June 07, 2016 @09:20PM (#11859347)
I am using your blog post about the mark and sweep-GC for my program! Thank you for publishing it! Very informative, entertaining and to-the-point. Thank you!
Re:Bone Lisp – Lisp Without Garbage Collection by munificent on Wednesday June 08, 2016 @12:24AM (#11860008)
You're welcome! I'm glad you enjoyed it. It was a lot of fun to write.
Re:Bone Lisp – Lisp Without Garbage Collection by RodgerTheGreat on Tuesday June 07, 2016 @11:46AM (#11855268)
Perhaps you'd enjoy some of my old Forth projects. I designed a portable VM with a Forth-based development toolchain and standard library. Included among the programs I wrote using this system were a variety of compilers and interpreters.

FiDo, a tiny JIT compiler: https://github.com/JohnEarnest/Mako/blob/master/demos/FiDo.f...

A Logo interpreter: https://github.com/JohnEarnest/Mako/blob/master/demos/Loko/L...

A garbage collector used by a number of games and programs: https://github.com/JohnEarnest/Mako/blob/master/lib/Algorith...

A custom systems programming language targeting the VM (Java) https://github.com/JohnEarnest/Mako/tree/master/tools/Stroye...

Re:Bone Lisp – Lisp Without Garbage Collection by DonHopkins on Tuesday June 07, 2016 @04:32PM (#11857550)
Wow, a full blown Logo interpreter written in Forth! Very cool! Nice looking code. Thanks for sharing!
Re:Bone Lisp – Lisp Without Garbage Collection by RodgerTheGreat on Tuesday June 07, 2016 @04:36PM (#11857577)
Loko (and many of the other programs) can be run interactively here:

http://johnearnest.github.io/Mako.js/?rom=Loko

Unfortunately some browsers have decided that backspace should navigate back, which makes typing at the Loko REPL rather awkward.

Re:Bone Lisp – Lisp Without Garbage Collection by kxyvr on Tuesday June 07, 2016 @03:33PM (#11857114)
Depending on how neurotic you want to get, Andrew Appel spent years working on SML and other functional programming language compilers and has written a few books about how to do it well. Namely, Compiling with Continuations:

http://www.amazon.com/Compiling-Continuations-Andrew-W-Appel...

and Modern Compiler Implementation in ML:

https://www.cs.princeton.edu/~appel/modern/ml/

There's a certain kind of equivalence between continuations and SSA. Mostly, I bring that up because if you go down the rabbit hole of designing a compiler in C, you'll find talk of SSA, but continuations are somewhat advantageous for designing functional compilers. If you're just looking to design an interpreter, Ben Pierce's book Types and Programming Languages does a good job at showing how to put together a simple functional language both theoretically and practically:

https://www.cis.upenn.edu/~bcpierce/tapl/

Re:Bone Lisp – Lisp Without Garbage Collection by codezero on Tuesday June 07, 2016 @09:21AM (#11854273)
Have a look at this if you want a guide: http://www.buildyourownlisp.com
Re:Bone Lisp – Lisp Without Garbage Collection by gte525u on Tuesday June 07, 2016 @08:24AM (#11853936)
Have you looked at scheme from scratch[1]?

[1] http://peter.michaux.ca/articles/scheme-from-scratch-introdu...

Re:Bone Lisp – Lisp Without Garbage Collection by akkartik on Tuesday June 07, 2016 @01:07PM (#11855871)
Re:Bone Lisp – Lisp Without Garbage Collection by e12e on Wednesday June 08, 2016 @05:04AM (#11860931)
All the other comments here are good. You might also want to take some advice from the SICL-project -- don't bootstrap from C, bootstrap from (a) lisp. If not Common Lisp, maybe Racket?

(Not that writing a lisp is a bad way to learn C of course!)

[1] "A Modern Implementation of the Common Lisp LOOP Macro", European Lisp Symposium https://www.youtube.com/watch?v=ZJr81DtSwUc

https://github.com/robert-strandh/SICL

Re:Bone Lisp – Lisp Without Garbage Collection by sesquipedalian on Wednesday June 08, 2016 @12:42AM (#11860069)
Very bare-bones implementation in one source file (+ 1 header) https://github.com/pedro-onate/eva/tree/84a62881c610ef23f9f1....

Later versions include GC, and bytecode compiler + VM.

Edit: I highly recommend SICP (dense, but elegant), and Matt Might's blog as resources.

Re:Bone Lisp – Lisp Without Garbage Collection by erik14th on Tuesday June 07, 2016 @11:50AM (#11855298)
Re:Bone Lisp – Lisp Without Garbage Collection by baldfat on Tuesday June 07, 2016 @11:16AM (#11855043)
Look here is a Racket (My Favorite Lisp) https://github.com/fraimondi/racket-asip

A Racket client for the Arduino Service Interface Protocol (ASIP)

Re:Bone Lisp – Lisp Without Garbage Collection by rjsw on Tuesday June 07, 2016 @08:35AM (#11854009)
Have you looked at lisp500 ?
Re:Bone Lisp – Lisp Without Garbage Collection by drhodes on Tuesday June 07, 2016 @11:29AM (#11855138)
Norvig's lispy (lisp in python) is a good one, http://norvig.com/lispy.html