Skip to content

Comment on Ask HN: What does a developer need to know to build their own Lisp from scratch?

Comments

There's a book for just that.

The title is "Build Your Own Lisp" and it is free to read [0].

You learn C and build your own Lisp dialect.

[0]: https://buildyourownlisp.com/

I gave that a try but because I didn't have any experience with C before, I found it hard to learn both C and how to build my own lisp. Instead "mal" (discussed here: https://news.ycombinator.com/item?id=31547901) makes no assumption about what language you want to use, and instead explains everything conceptually so you can implement your lisp in any language you want.

The repository of mal also features a implementation for basically any type of language for reference, in case you get stuck.

Fun fact: mal originally was made to see if you could implement a lisp with just GNU Make macro language (spoiler: you can!), after the author saw someone else making a lisp language in bash.

Last time I read about the book (I have it and started working through it.), people did not recommend it (here on HN), due to how the author chooses to implement things later on in the book. Instead people recommended looking at MAL ("Make A Lisp") repos.

I started working through the book using Rust instead of C, which allowed me to parse things in a safe way, making sure, that my grammar covers all cases in a typesafe way. If anyone works through the book, I recommend avoiding the use of C, which is used in the book itself.

However, before reading part of the book, I already had watched part of the Minikanren uncourse, where Will Byrd writes a Scheme parser (well, the basic part of it, not implementing the whole standard), explaining everything quite well, which made me confident, that I could change the language I use to implement the things in the book and still get things right.

So my recommendation is to look at the Minikanren Uncourse videos. It should be in the first 4 videos of the series.

Thank you for your comment.

I did not knew about the existence of MAL.

I will check it out.

Moreover, in line of the original question asked, I would just suggest The Little Schemer. Here you not only learn the language and how to think recursively, but you also learn how to implement a lot of the in-built and library functions that comes with languages.

The Little Schemer was a life changing book for me.

I would also definitely recommend The Little Schemer. Big fan of the 10 rules here : ) It might not be the easiest to understand in some parts though.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.