0

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

 1 year ago
source link: https://news.ycombinator.com/item?id=31547765
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

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

Ask HN: What does a developer need to know to build their own Lisp from scratch?
7 points by stolen_biscuit 2 hours ago | hide | past | favorite | 5 comments
Assuming the developer is competent in their language of choice and want to implement lisp in that language. What's at the heart of lisp that makes it so simple and elegant?
Not much really; I would recommend working through SICP [0], it is fun and in the end your know a lot and can move on from there to even more advanced topics.

It together with the YouTube recordings of the lectures about the book will give you many AHA moments about why it’s so elegant etc.

Including topics like types and a prolog like logic language.

[0] https://en.m.wikipedia.org/wiki/Structure_and_Interpretation...

Why is Lisp/Scheme a good candidate for something to implement oneself? Because it has hardly any syntax, so writing the parser is relatively easy compared to writing the parser for other languages.

> What's at the heart of Lisp that makes it so simple and elegant?

In terms of implementing it, probably the Cons Cell. The insight being that the heart of Lisp is pairs, not lists:

https://www.gnu.org/software/emacs/manual/html_node/elisp/Co...

https://cs.gmu.edu/~sean/lisp/cons/

If by "lisp from scratch" you mean an s-expression interpreter that can run programs like recursive exponentiation or recursive fibonnaci, very little. You can do that in a low few hundred lines of code.

If you mean for the full power of a lisp then you still have to pick: for Scheme that might be call-with-cc and hygienic macros. For Common Lisp that might be regular macros and reader macros. Those take more code and thought.

s.gif
IMO call-with-cc AND regular macros is what one should implement for toy language. Hygienic macros are too hard to understand let alone implement, while ordinary macros are more powerful (and maintainability does not matter much for toy language) and relatively easy to implement. And call-with-cc is too fun to skip.
the classic introduction to building a lisp (interpreter) in different programming languages is:

https://github.com/kanaka/mal

s.gif
Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search:

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK