top | item 6700103

Try Hy

178 points| proppy | 12 years ago |try-hy.appspot.com

64 comments

order
[+] agentultra|12 years ago|reply
I did a little presentation on Hy at Pycon Canada earlier this year [1].

Hy has come a ways since then even. Shortly after that talk we added succinct syntax aliases for QUOTE and QUASIQUOTE. And we added a nice clojure-inspired core library.

It's a cool little language. Fun to hack on. You could learn a few things if you do. And I do hope that we can start help creating documentation for the Python AST module via this project.

[1] http://pyvideo.org/video/2328/hy-a-lisp-that-compiles-to-pyt...

[+] mkramlich|12 years ago|reply
A+ for presentation
[+] ceautery|12 years ago|reply
Indeed; that was fantastic.
[+] anaphor|12 years ago|reply
So it just desugars into Python? I see there is a section in the documentation for macros, but there's nothing there. Does it support AST macros right now? I thought of doing something similar to this except doing some kind of static or gradual typing (that would be a larger project though).
[+] paultag|12 years ago|reply
Original author of hylang here - because lisp is homoiconic, you have real macros, not AST macros; although the distinction isn't exactly clear, it's nice to have them as first-class members of the language, and allow them to avoid caring about stmt vs expr internally.

Happy to answer questions.

[+] Foxboron|12 years ago|reply
It desugars into python's AST, not python.
[+] haney|12 years ago|reply
I've had similar ideas. I really like the batteries that are included with python but I would like to be able to add type annotations that are enforced to my code base for type safety.

I also really like the idea of being able to extend the language with macros. Hy certainly seems like a good start towards a language like this.

[+] zaph0d|12 years ago|reply
Very nice. Surface syntax (and some semantics like interop) seem to be heavily inspired by Clojure :-)
[+] girvo|12 years ago|reply
Hy is neat. I love Lisps that "compile" or are embedable within host scripting languages.

My favourite one to hack on (owing to my PHP ability) is Pharen[0]. Very neat little Lisp that compiles down to PHP, which is very fun to play with. I highly suggest giving Hy a go if you're a Pythonista, as you can learn a lot about programming in general by seeing how these sorts of languages map to the host. Very fun to hack on, too!

[0]: http://scriptor.github.io/pharen/

[+] dmoney|12 years ago|reply
To quote Dark Helmet, "What the hell am I looking at?"
[+] vezzy-fnord|12 years ago|reply
Not bad. Could be a very useful tool to teach Python programmers Lisp, although I don't think Python benefits much from converting its syntax to sexprs.
[+] nine_k|12 years ago|reply
If this thing supports macros (and it seems to, see the pipe example in the tutorial), it may be more powerful than Python — as you'd expect from a Lisp.
[+] andrelaszlo|12 years ago|reply
Apparently without TCO :(

    File "<input>", line 1, in fac
    File "<input>", line 1, in fac
    File "<input>", line 1, in fac
    RuntimeError: maximum recursion depth exceeded
    =>
[+] mattholtom|12 years ago|reply
Heh, recognized reverse polish notation right away. One of the companies I interviewed at last year had me program an RPN calculator fed by CSV spreadsheets. Weirdest thing I've made to date by a pretty wide margin.
[+] matchu|12 years ago|reply
"+ 41 1" more closely resembeles straight-up non-reverse Polish notation. Its cool property is that it has unambiguous grouping without parentheses.

Reverse Polish notation's even cooler property is that, in addition to the unambiguity, it can easily be evaluated from left to right with a stack: If you see a operand, push it onto the stack. If you see an operator, pop two operands off the stack, compute, and push the result onto the stack. By the end you'll have a one-element stack with your result.

Really what we're seeing here, though, is a language without infix operators: all functions are of the form "<name> <operand1> <operand2>…", but grouping still works as expected.

http://en.wikipedia.org/wiki/Polish_notation

http://en.wikipedia.org/wiki/Reverse_Polish_notation

[+] sockgrant|12 years ago|reply
They had you do that in the interview?
[+] jackhammons|12 years ago|reply
Incredible implementation.
[+] anaphor|12 years ago|reply
It's not that difficult to parse s-expressions and generate code, which is what this does.
[+] petercooper|12 years ago|reply
What blew my mind is this actually worked on my iPod Touch and brought up the keyboard. Usually "dynamic" JavaScript keyboards or games totally fail on there..
[+] hcarvalhoalves|12 years ago|reply
Excellent. I thought what a LISP on top of the Python runtime would be (like Clojure + JVM), didn't knew this existed already.
[+] a3_nm|12 years ago|reply
"(defun f x (x))" gives a Python stack trace.
[+] Sunlis|12 years ago|reply
Finally my knowledge of Scheme comes in handy!
[+] talles|12 years ago|reply
Love at first sight with the presentation
[+] d0m|12 years ago|reply
I think this is fucking amazing.