5 ms·
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 (y
by hkjgkjy 10y ago
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.
- gte525u 10y agoHave you looked at scheme from scratch[1]? [1] http://peter.michaux.ca/articles/scheme-from-scratch-introduction http://peter.michaux.ca/articles/scheme-from-scratch-introdu...
- rjsw 10y agoHave you looked at lisp500 ?
- codezero 10y agoHave a look at this if you want a guide: http://www.buildyourownlisp.com http://www.buildyourownlisp.com
- baldfat 10y agoLook here is a Racket (My Favorite Lisp) https://github.com/fraimondi/racket-asip https://github.com/fraimondi/racket-asip A Racket client for the Arduino Service Interface Protocol (ASIP)
- drhodes 10y agoNorvig's lispy (lisp in python) is a good one, http://norvig.com/lispy.html http://norvig.com/lispy.html
- RodgerTheGreat 10y agoPerhaps 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.fs https://github.com/JohnEarnest/Mako/blob/master/demos/FiDo.f... A Logo interpreter: https://github.com/JohnEarnest/Mako/blob/master/demos/Loko/Loko.fs 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/Algorithms/Garbage.fs 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/Stroyent https://github.com/JohnEarnest/Mako/tree/master/tools/Stroye...
- DonHopkins 10y agoWow, a full blown Logo interpreter written in Forth! Very cool! Nice looking code. Thanks for sharing!
- RodgerTheGreat 10y agoLoko (and many of the other programs) can be run interactively here: http://johnearnest.github.io/Mako.js/?rom=Loko 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.
- erik14th 10y agohttps://github.com/JeffBezanson/femtolisp https://github.com/JeffBezanson/femtolisp
- akkartik 10y agohttp://akkartik.name/post/wart http://akkartik.name/post/wart
- munificent 10y agoIf you just want a GC, here's a tiny one I wrote: https://github.com/munificent/mark-sweep https://github.com/munificent/mark-sweep And an article I wrote about it: http://journal.stuffwithstuff.com/2013/12/08/babys-first-garbage-collector/ http://journal.stuffwithstuff.com/2013/12/08/babys-first-gar... This was the inspiration for uLisp's GC (http://www.ulisp.com/show?1AWG 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/ http://wren.io/ https://github.com/munificent/wren https://github.com/munificent/wren
- hkjgkjy 10y agoI 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!
- munificent 10y agoYou're welcome! I'm glad you enjoyed it. It was a lot of fun to write.
- kxyvr 10y agoDepending 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/dp/052103311X http://www.amazon.com/Compiling-Continuations-Andrew-W-Appel... and Modern Compiler Implementation in ML: https://www.cs.princeton.edu/~appel/modern/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/ https://www.cis.upenn.edu/~bcpierce/tapl/
- sesquipedalian 10y agoVery bare-bones implementation in one source file (+ 1 header) https://github.com/pedro-onate/eva/tree/84a62881c610ef23f9f1ac9e6199bca105d5acb9 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.
- e12e 10y agoAll 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://www.youtube.com/watch?v=ZJr81DtSwUc https://github.com/robert-strandh/SICL https://github.com/robert-strandh/SICL