News for hackers. Stuff that matters.
Re:How to Write a Lisp Interpreter in Python (2010) by marcpaq on Monday October 24, 2016 @09:48AM (#12778708)
I'm always impressed how the magic of interpreters and compilers can be explained so succinctly.

Inspired by Jonesforth, I wrote a complete Lisp interpreter in a single ARM assembly file: https://github.com/marcpaq/arpilisp

Re:How to Write a Lisp Interpreter in Python (2010) by cagmz on Monday October 24, 2016 @11:56AM (#12779957)
How long did it take you? The documentation is A+ (it reminds me of this compiler: https://github.com/thejameskyle/the-super-tiny-compiler ).
Re:How to Write a Lisp Interpreter in Python (2010) by marcpaq on Monday October 24, 2016 @12:16PM (#12780154)
I estimate it took 60-70 hours, of which 2/3 of that was for the documentation.

Thanks for the compliment and the link to TSTC. I'll add it to my personal list.

Re:How to Write a Lisp Interpreter in Python (2010) by dancek on Monday October 24, 2016 @04:07PM (#12782365)
You are my new hero.

I've become interested in Lisp every couple of years. This fall I even learned Clojure and implemented a Lisp interpreter in Python. I searched a lot for any open-source Lisp implementation in assembly, but found none. Here it is!

I thought a lot about bootstrapping, too, since apparently almost every compiler is written in C these days. Somewhere I got the idea that in the 1970s someone wrote a compiler in assembly and that was used to bootstrap the first C compiler. Guess I'm a romantic, but for me it's important that we know how to get where we are now. Having a high-level language implemented in assembly is quite essential to that, IMO.

Re:How to Write a Lisp Interpreter in Python (2010) by rm445 on Monday October 24, 2016 @05:01PM (#12782858)
I think there's a separate Lisp lineage anyway, wherein someone in the 1960s wrote a minimal machine-code interpreter, and ever since lispers have been writing interpreters on top of other Lisps and revising them to emit compiled code along the way. We would still have Lisp compilers if C never existed.
Re:How to Write a Lisp Interpreter in Python (2010) by jackhack on Monday October 24, 2016 @03:19PM (#12781927)
This is brilliant!

I've failed more than once to wrap my stupid brain around lisp but after reading your code, something clicked. I dare say I think I get it! https://github.com/marcpaq/arpilisp/blob/master/arpilisp.s

It's all extraordinarily clean and clear (and must set a new world record for most thorough comment --1120 lines!)

Re:How to Write a Lisp Interpreter in Python (2010) by pjmlp on Monday October 24, 2016 @02:29PM (#12781442)
Very good quality congratulations!

While quickly reading through it, my first idea was getting the PI to boot directly to it. :)

Re:How to Write a Lisp Interpreter in Python (2010) by rcarmo on Monday October 24, 2016 @08:10AM (#12778097)
Obligatory link to today's best solution, using the Python AST and running straight off bytecode: http://hylang.org
Re:How to Write a Lisp Interpreter in Python (2010) by agumonkey on Monday October 24, 2016 @08:33AM (#12778213)
Re:How to Write a Lisp Interpreter in Python (2010) by pryelluw on Monday October 24, 2016 @11:15AM (#12779529)
I've always found Hy interesting, but cannot picture anyone using it in production. Are there any real live examples?
Re:How to Write a Lisp Interpreter in Python (2010) by rcarmo on Monday October 24, 2016 @01:33PM (#12780931)
The maintainers quoted having a few customers using it, but here's my stuff: http://github.com/rcarmo/sushy
Re:How to Write a Lisp Interpreter in Python (2010) by pryelluw on Monday October 24, 2016 @05:13PM (#12782955)
That code is more readable than I expected. :) May you share more about the experience of using it? Do you keep a blog?
Re:How to Write a Lisp Interpreter in Python (2010) by rcarmo on Monday October 24, 2016 @06:38PM (#12783529)
Erm. My blog runs on it, it's the demo site :)
Re:How to Write a Lisp Interpreter in Python (2010) by pryelluw on Monday October 24, 2016 @07:11PM (#12783735)
Well, ok. :)

I tweeted the repo link to the HyLang account.

Re:How to Write a Lisp Interpreter in Python (2010) by jacquesm on Monday October 24, 2016 @07:50AM (#12778028)
Original HN Submission + discussion here:

https://news.ycombinator.com/item?id=1745322

(and many re-submissions after that)

Follow up:

https://news.ycombinator.com/item?id=1746916

Re:How to Write a Lisp Interpreter in Python (2010) by dancek on Monday October 24, 2016 @03:55PM (#12782262)
For anyone wanting to try something similar yourself, I highly recommend MAL. It's a Lisp dialect designed to be a learning tool: there's a nice guide for implementing the interpreter. It doesn't take much away from the learning, but it really lessens the possible frustration a lot. https://github.com/kanaka/mal/blob/master/process/guide.md

Just in case anyone is interested, here's my implementation in Python 3.5+. I'm guessing it took me about 15 hours to write. https://github.com/dancek/mal/tree/python3-dancek/python3-da...

Of course, Peter Norvig's followup to the linked article may also interest anyone who read this far: http://norvig.com/lispy2.html

Re:How to Write a Lisp Interpreter in Python (2010) by atobe on Tuesday October 25, 2016 @03:19PM (#12790828)
Is LISP still relevant? ;-)

I'm curious whether folks think the ideas of LISP are still resonant and powerful in the startup world and wider industry.

This is different from the question of inspiration. Yes, I admire.

Does PG, for instance, still think that startups can have 'secret' technical advantages and use strategies like 'running upstairs', i.e. choosing to do hard things as a competitive advantage.

By ideas of LISP I mean things like programs-as-data and a small kernel from which the system is bootstrapped.

Re:How to Write a Lisp Interpreter in Python (2010) by krylon on Monday October 24, 2016 @08:00AM (#12778062)
He he, I wrote a (primitive) Lisp interpreter in Python once. It was crappy and really slow, but it had lexical scoping and a (naive) macro system. Fun times... ;-)
Re:How to Write a Lisp Interpreter in Python (2010) by whistlerbrk on Monday October 24, 2016 @01:33PM (#12780932)
Along the same lines may I say buildyourownlisp.com somehow manages to be a great intro text to C as well as lisp. Highly recommended
Re:How to Write a Lisp Interpreter in Python (2010) by keithgabryelski on Monday October 24, 2016 @01:48PM (#12781064)
Here is my version of a lisp interpreter in python:

https://github.com/keithgabryelski/plisp

it's not meant to be pythonic -- it's meant to readable and organized

my inspiration was Interpreting LISP by Gary D. Knott written in 1997 (the pdf of it is included in the repository)

Re:How to Write a Lisp Interpreter in Python (2010) by rosstex on Monday October 24, 2016 @02:26PM (#12781421)
This is currently the final project of CS61A, the introductory CS course taught at UC Berkeley.

https://inst.eecs.berkeley.edu/~cs61a/fa14/proj/scheme/ (no link for the current semester is up yet)

Re:How to Write a Lisp Interpreter in Python (2010) by ojno on Monday October 24, 2016 @07:52AM (#12778038)
Surely something more like

(how (in 'python (write (interpreter 'lisp))

:-P

Re:How to Write a Lisp Interpreter in Python (2010) by pavelludiq on Monday October 24, 2016 @08:07AM (#12778090)
More like:

  (howp (write (interpreter :of :lisp
                            :in :python))))
Re:How to Write a Lisp Interpreter in Python (2010) by mmarx on Monday October 24, 2016 @08:45AM (#12778256)
> howp

“how?” is not a predicate (i.e. something that returns a Boolean value), so it wouldn't be named howp.

Re:How to Write a Lisp Interpreter in Python (2010) by qubex on Monday October 24, 2016 @11:32AM (#12779701)
Somebody read the Jargon File...
Re:How to Write a Lisp Interpreter in Python (2010) by agumonkey on Monday October 24, 2016 @08:32AM (#12778210)
'social-problems-of-lisp
Re:How to Write a Lisp Interpreter in Python (2010) by vram22 on Monday October 24, 2016 @02:58PM (#12781734)
Please read the post title again.

A minimal version would be more like:

# REPL

def interpret_lisp():

    while not control_C_pressed():

        print(eval(read()))
where those functions would have to be defined, of course.

:)

Re:How to Write a Lisp Interpreter in Python (2010) by erikb on Monday October 24, 2016 @07:48AM (#12778020)
This is from 2010. Please mark in the title.