Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Build Your Own Lisp (buildyourownlisp.com)
115 points by curious16 on May 28, 2023 | hide | past | favorite | 12 comments


If you want to learn languages, implementing a lisp interpreter is a great exercise, and lots of fun too. Every time I come across a new language I want to give a try, creating a lisp interpreter is one of the first things I do.

If you're curious but want a more language-agnostic guide, mal (Make a lisp) is a language+project that has a guide you can follow along with basically any language, and if you get stuck, you can look at already implemented versions in practically any language: https://github.com/kanaka/mal

Personal favorite implementations of mal: nasm (assembly) (https://github.com/kanaka/mal/tree/master/impls/nasm) and wasm (https://github.com/kanaka/mal/tree/master/impls/wasm)

mal has also been discussed many times on HN (which is probably how I came across it the first time too) for close to a decade by now: https://hn.algolia.com/?query=kanaka%2Fmal


Agreed. BYOL and MAL are excellent work.

I had fun making an interpreter in ARM assembly:

https://github.com/marcpaq/arpilisp

Since the world obviously needs another book on Lisp-making, I'm thinking of porting it to arm64 and expanding it into a book.


I agree about MAL (which I also came across thanks to HN). I've seen comments on HN to the effect that you are better off looking at the source code of an open lisp to understand how to do it properly, but I found working through MAL really educational and motivating. I was really pleased when I got my MAL implementation (in C#) to self-host.

I only really cheated once (by looking at an existing implementation) and that was when I was implementing macros. I discovered I'd misread something in the MAL guide and was doing the correct things, but in the wrong order.

I'm now doing MAL again in Rust as a way of going up the Rust learning curve, and when I've done that (or enough) I'm going to see if I can code a garbage collected version of MAL (probably using 'Crafting Interpreters' as a guide - another really superb instructional resource).


I think MAL is rather demanding. Each step wants you to write specific functionalities which may not be absolutely crucial. Sometimes it's hard to assemble pieces in coherent enough MAL-satisfying whole. I guess MAL wants to be able to test automatically everything, but it still feels more problematic than it should.


I worked through this years ago and was rather disappointed, I felt the hand holding/explanations were not well balanced; it walks you through everything like you have no programming experience but explains things like you do have programming experience. The exercises were ok but not great. It left me with far more questions than answers and only slightly better at C than I was before.

But I am a hack in everyway, so it could just be me.


I like the humour "Mike Tyson • Your typical Lisp user" :-) https://buildyourownlisp.com/chapter1_introduction#who_this_...


I followed the exercises in this book coming up on a decade ago. It was I valuable to my growth as a developer. The author, OrangeDuck, has many worthwhile projects. If you are learning C, it's worth checking out their Cello project.


Recent repeat, but I think I used the template that made the website in 1995. Still amusing.

https://hn.algolia.com/?dateRange=all&page=0&prefix=false&qu...


Bookmarked. In the same spirit, there’s also codecrafters.io that covers Building your own Git, Docker, Redis, etc.


When I was an undergrad, having newly read SICP, I start to write my own lisp in.... drumroll... matlab!!! I actually made quite a bit of progress before giving up.

Ah, to be young again!


Here is one implementation of a lisp (mal specifically) in matlab: https://github.com/kanaka/mal/blob/dcf8f4d7b9cf7b858850a04a0...

Only 260 lines of code, pretty concise :)


Beautiful




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

Search: