Live data from Hacker News

(How to Write a (Lisp) Interpreter (In Python)) (2010)

norvig.com

31–40 of 101 posts

Re: (How to Write a (Lisp) Interpreter (In Python)) (2010)

#32
At some point I translated this demo into es6 if anyone's interested [0].

The focus was really on writing the cleanest idiomatic es6 I could (at the time :)). Check out the tests to see how far I got [1]

Pretty fun exercise =)

[0]: https://github.com/djtriptych/es6-lisp

[1]: https://github.com/djtriptych/es6-lisp/blob/master/test/lisp...

Re: (How to Write a (Lisp) Interpreter (In Python)) (2010)

#33

At some point I translated this demo into es6 if anyone's interested [0]. The focus was really on writing the cleanest idiomatic es6 I could (at the time :)). Check out the tests to see how far I got [1] Pretty fun exercise =) [0]: https://github.com/djtriptych/es6-lisp [1]: https://github.com/djtriptych/es6-lisp/blob/master/test/lisp...

It's a fun thing to try, since Javascript almost was to be a Lisp at inception!

Re: (How to Write a (Lisp) Interpreter (In Python)) (2010)

#34
post #19

Or you can just from fakelisp import * And turn your Python into a Lisp. https://github.com/akalenuk/fakelisp

Not exactly the same (doesn't embed into the source like this did), but I believe Hylang[0] is the best Lisp package available for modern Python. [0] https://github.com/hylang/hy

Ah, yes! Fakelisp page references Hylang too, although with a broken link.

Re: (How to Write a (Lisp) Interpreter (In Python)) (2010)

#35

> The beauty of Scheme is that the full language only needs 5 keywords and 8 syntactic forms. Is there a learning resource that covers exactly this for those wanting to write software in lisp in 2024? As "first principle thinkers" in some ways all hackers crave for that "fundamental building blocks approach", a bit like wanting to know how we go from transistors to full computers and every step along the way. Most of…

SICP

Re: (How to Write a (Lisp) Interpreter (In Python)) (2010)

#36

At some point I translated this demo into es6 if anyone's interested [0]. The focus was really on writing the cleanest idiomatic es6 I could (at the time :)). Check out the tests to see how far I got [1] Pretty fun exercise =) [0]: https://github.com/djtriptych/es6-lisp [1]: https://github.com/djtriptych/es6-lisp/blob/master/test/lisp...

It's a fun thing to try, since Javascript almost was to be a Lisp at inception!

Someone once said Javascript is a "Scheme-like language with C-like syntax".

Always loved that and ashamed I can't remember the original author of the quote.

Not Crockford... Maybe Michael Fogus?

Re: (How to Write a (Lisp) Interpreter (In Python)) (2010)

#37

> The beauty of Scheme is that the full language only needs 5 keywords and 8 syntactic forms. Is there a learning resource that covers exactly this for those wanting to write software in lisp in 2024? As "first principle thinkers" in some ways all hackers crave for that "fundamental building blocks approach", a bit like wanting to know how we go from transistors to full computers and every step along the way. Most of…

I suppose 5 is better than lots but you can totally write a lisp with zero keywords. I'm not sure what a syntactic form means here - dot as in dotted pair, nil, quote, quasiquote, parens? Having trouble coming up with 8 distinct syntactic things. The basis set underlying lisp is something like the lambda calculus with optional delayed evaluation, a product type and some file I/O. The optimal basis set for computation…

> The optimal basis set for computation is either non-unique

If one adds a requirement of additively optimal program length as in [1], then Binary Lambda Calculus is a good candidate.

[1] https://gist.github.com/tromp/86b3184f852f65bfb814e3ab0987d8...

Re: (How to Write a (Lisp) Interpreter (In Python)) (2010)

#38
This code is really beautiful and makes a lot of hard things easy to understand. I read this article many times before I developed the confidence to do it myself.

Python gives you a lot of things for free. Writing the lisp in C is quite the adventure in its own way.

Re: (How to Write a (Lisp) Interpreter (In Python)) (2010)

#39
post #7

I would prefer a python interpreter written directly in rv64 assembly with a near 0-SDK. Would run on x86_64 and arm64 with a rv64 interpreter (ofc with some code paths adaptation).

I made a lisp that's somewhat close to what you described. It's a freestanding lisp that targets the Linux kernel directly. No libraries, not even libc.

https://github.com/lone-lang/lone

Re: (How to Write a (Lisp) Interpreter (In Python)) (2010)

#40

> The beauty of Scheme is that the full language only needs 5 keywords and 8 syntactic forms. Is there a learning resource that covers exactly this for those wanting to write software in lisp in 2024? As "first principle thinkers" in some ways all hackers crave for that "fundamental building blocks approach", a bit like wanting to know how we go from transistors to full computers and every step along the way. Most of…

Many years ago I wrote a simple programming language that would macro expand into lambda calculus statement that could then be compiled down to different sets of combinators - the simplest being just S & K, which are pretty fundamental given how simple they are. The fact that you can express things like recursion in the lambda calculate (see name of our hosts on this site) and therefore in combinators still amazes me…

> expand into lambda calculus statement that could then be compiled down to different sets of combinators

This approach can be reasonably efficient for implementing Haskell, as shown in [1] and the much more concise [2].

[1] https://github.com/augustss/MicroHs

[2] https://crypto.stanford.edu/~blynn/compiler/

Post reply on HN