from Hacker News

Cell: Lisp in Javascript

by SoCool on 8/19/12, 8:33 PM with 19 comments

  • by crescendo on 8/19/12, 10:21 PM

    Hi everyone, original author here. Thanks for all the feedback! My friend posted this before it was really ready for public consumption.

    My goal here was to learn how Lisp works at a really low level. I'm planning to add the features you would expect from a Lisp (e.g. macros) very soon.

  • by xyzzyz on 8/19/12, 9:24 PM

    I found one bug: you cannot create a zero argument lambda, e.g. (lambda () 42) will not work. You could also benefit from separate `let' construct, because simulating them with lambdas is a bit painful.

    Apart from that, it works quite nicely (I was positively surprised you went for lexical scoping), but without macros, you can hardly say it's a Lisp, it's a language with Lispy syntax.

  • by jacques_chester on 8/20/12, 12:29 AM

    Consider a different name -- "Cells" is the name of a cool Common Lisp library by a ... let's say notorious ... Lisp programmer.

    http://common-lisp.net/project/cells/

  • by alol on 8/19/12, 9:21 PM

    Cool. I have been working through the lessons in Nathan's University (http://nathansuniversity.com/) which take you writing a Lisp interpreter (though admittedly with less rigor than this project) in Javascript.

    Definitely recommended if you want a starting point for something similar and don't know where to begin.

  • by ganley on 8/20/12, 12:34 PM

    Gotta shout out to my own Lisp-in-JavaScript interpreter from long, long ago: http://joeganley.com/code/jslisp.html ... far less complete than this, but perhaps interesting to someone for archeological reasons or something.
  • by archgoon on 8/19/12, 11:06 PM

    Thank you for implementing command history :).

    There is a slight bug though. Since the position gets updated after the position is calculated, the displayed value is out of sync.

    So entering

    1

    2

    3

    And then typing: UP (3), UP (2), DOWN (1)

    Displays 1, rather than 3.

  • by jfaucett on 8/19/12, 9:52 PM

    nice job! I like how clean the source is, it would be really easy to extend or use as a base for writing ones own interpreter.
  • by cabalamat on 8/19/12, 10:30 PM

    Why does this happen:

        (def a 3)
        3
    
        a
        null
    
    a should be 3, not null.
  • by diminish on 8/19/12, 9:03 PM

    good work, just was checking arc in js; http://jonathan.tang.name/files/arclite/index.html and was surprised to see cell on hn.
  • by keithgabryelski on 8/20/12, 9:58 AM

    here is a basic lisp interpreter written in python: https://github.com/keithgabryelski/plisp