Julien Danjou: Hy, Lisp in Python
I've meant to look at Hy since
Paul Tagliamonte started to talk to me about
it, but never took a chance until now.
Yesterday, Paul indicated it was a good time for me to start looking at it,
so I spent a few hours playing.
But what's Hy?
Python is very nice: it has a great community and a wide range of useful
libraries. But let's face it, it misses a great language.
Hy is an implementation of a
Lisp on top of
Python.
Technically, Hy is built directly with a custom made parser (for now) which
then translates expressions using the
Python AST module to generate
code, which is then run by Python. Therefore, it shares the same properties
as Python, and is a Lisp-1 (i.e. with a single namespace for symbols and
functions).
If you're interested to listen Paul talking about Hy during last PyCon US, I
recommend watching his lightning talk. As the name implies, it's only a few
minutes long.
<iframe allowfullscreen="allowfullscreen" class="shadow" frameborder="0" height="374" src="http://www.youtube.com/embed/1vui-LupKJI?wmode=transparent&autohide=1&egm=0&hd=1&iv_load_policy=3&modestbranding=1&rel=0&showinfo=0&showsearch=0#t=16m14s" width="500"></iframe>
Does it work?
I've been cloning the code and played around a bit with Hy. And to my
greatest surprise and pleasure, it works quite well. You can imagine writing
Python from there easily. Part of the syntax smells like
Clojure's, which looks like a good thing since they're
playing in the same area.
You can try a Hy REPL in your Web browser if you
want.
Here's what some code look like:
(import requests)
(setv req (requests.get "http://hy.pault.ag"))
(if (= req.status_code 200)
(for (kv (.iteritems req.headers))
(print kv))
(throw (Exception "Wrong status code")))
This code would ouput:
('date', 'Wed, 03 Apr 2013 12:09:23 GMT')
('connection', 'keep-alive')
('content-encoding', 'gzip')
('transfer-encoding', 'chunked')
('content-type', 'text/html; charset=utf-8')
('server', 'nginx/1.2.6')
As you can see, it's really simple to write Lispy code that really uses
Python idioms.
There's obviously still a lots of missing features in Hy. The language if
far from complete and many parts are moving, but it's really promising, and
Paul's doing a great job implementing every idea.
I actually started to hack a bit on Hy, and will try to continue to do so,
since I'm really eager to learn a bit more about both Lisp and Python
internals in the process. I've already send a few patches on small bugs I've
encountered, and proposed a few ideas. It's really exciting to be able to
influence early a language design that I'll love to use! Being a recent fan
of Common Lisp, I tend to grab the good stuff from it to add them into Hy.
Daniel Pocock posted
Let's work through each of the steps in the diagram:
The upstream release
I was going to post this yesterday, but some might have thought that it was a joke. April 1st is always an annoying day to communicate real information. If you have been fond of the way Debian and Ubuntu manage multiple PostgreSQL versions in parallel, you can now have the same on OS X with Homebrew:
<iframe allowfullscreen="allowfullscreen" frameborder="0" height="299" src="http://www.youtube.com/embed/1vui-LupKJI?wmode=transparent&autohide=1&egm=0&hd=1&iv_load_policy=3&modestbranding=1&rel=0&showinfo=0&showsearch=0#t=16m14s" width="400"></iframe>
With GNOME 3, if you want to override a setting with a new site default,
assuming your app has been updated to use the new
So one of the first things I need to do when I get my apartment today is get
the electricity on. I've actually already ordered ADSL, which shows you what
I think is more important, but without electricity, there is no Internet...
It would appear that in 2007, Queensland opened up its electricity and gas
markets to "full retail competition".
I have just uploaded
After
So you probably heard that I have that little new project of mine: 
This weekend I have mostly been reading
Look! There s a cross-over between the Stable bug count and the Testing bug count around 6/2012. Since then, Stable has actually been more buggy the testing.
What should we (as a project) do? Why is stable so unloved during the freeze? Do we have too long a freeze?
Hilariously, this makes me think I should be suggesting users to switch from stable to testing when the crossover happens during the release cycle.
Has there been previous discussion of this?
The goal of this article is to illustrate how to manage Python code which includes comments in UTF-8 characters inside a latin-1 source org-mode for LaTeX export.
Note that I ve pasted in wordpress the HTML generated by org-mode, so I hope it isn t broken too much.
My typical use case is a french lecture on Python where the text is written in french, as well as some of the code comments and examples
We ll use org-mode s babel module to include and manage the Python