Hacker News new | past | comments | ask | show | jobs | submit login
Hy, a Lisp that compiles to Python (github.com/hylang)
115 points by cabalamat on Feb 10, 2014 | hide | past | favorite | 60 comments



This terminal cracked me up: http://try-hy.appspot.com/


thanks for the share. It's hilarious!


Looks bad in windows chrome though. this looks better to me:

  #hy-console {
      margin-top: 191px;
      margin-left: 223px;
      -webkit-transform: rotateX(-20deg) rotateY(5deg) rotateZ(5deg) skewX(4deg);
      transform: rotateX(-20deg) rotateY(5deg) rotateZ(5deg) skewX(4deg); 
  }


I'll repost two recent blogposts about Hy that have been on Hackernews recently.

http://fox.devport.no/?p=82

http://asylum.madhouse-project.org/blog/2014/01/26/hy-the-lo...


Language author here :)

if anyone wants to learn more, we have a pretty sweet team over in #hy on freenode, and have some MLs and stuff sprinkled around.


i'll ask you the same questions i asked the parenjs author, and which i think are pretty much faqs if you're developing a language-hosted lisp dialect. (some of them, like the interop ones, are answered in the hy docs, but it would be nice to have a quick up-front list for reference).

* lisp-1 or lisp-2?

* scoping rules?

* 1-way or 2-way python interop?

* lisp support for python objects?

* any support for tco or loop/recur?

* reader macros?

* speed penalty relative to native python?


* lisp-1 (Python rules)

* Python (sucks)

* 2-way

* Yep! CLOS syntax

* Yep! hy.contrib.loop - to be promoted soon

* Yep, they're OK, relies on dispatch char that's static

* Very little, actually - it compiles to (pretty sane) Python AST / Bytecode - so good pdb works to debug Hy :)


awesome, looking forward to checking it out :) shame about the scoping, as you say, but i guess the python interop made it the natural choice.


I can answer most of these just from reading the stuff linked here and educated guesses.

lisp-1, bastardized-lexical (like python, though you could create your own binding constructs with macros), 2-way, yes, yes (loop/recur, no TCO afaict or trampolining), yes, yes


trampolining - confirmed


Then you should give this a read if you haven't: http://www.cs.indiana.edu/~dfried/ts.ps

tl;dr you can actually generalize trampolining quite a bit in order to get co-operative threading.


Interesting, thanks for that! I'll read it over on the train in the morning and see if I can't fudge it in :)


In a way Hy seems to be to Python what Clojure is to Java / JavaScript. Did Clojure influence you and if so, how?

Congrats and nice looking terminal : )


Either I have (good or bad?) luck or I've got some zeitgeist hunch or something, but first I had a convincing WIP of implementing Ruby in RPython when Topaz went out, and now while I'm working on a Lisp[0] — again in RPython — comes Hy.

Well at least Hy is markedly different, as my goal is not to compile to Python AST/bytecode, but "merely" be implemented in (R)Python (and C for LLVM) with no access to the Python runtime.

[0]: https://github.com/lloeki/wasp


You see the wierd signs in the description for hy? Its actually a wierd way of spelling Hymenoptera! So, that further confirms your zeitgeist hunch.

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


I think it's natural inclination. There's a basic Scheme implementation in Pypy, and I'm also working on a Lisp using RPython: https://github.com/Wilfred/trifle


Looks great! Just a heads up here for a name clash of another wasp lisp.

https://github.com/swdunlop/WaspVM


Great movement from the community to show some love to FP. I really like Clojure, and will give Hy a try as well. FP really forces you to write better code and somehow your thinking starts to change slowly. What I realised is that after I started to write Clojure, I am writing much more functions in Python as well. If you haven't tried yet, give FP some chance.


I just want to note that Lisp does not really imply functional programming. Hy is nothing more then Python with Lisp syntax and the awesomesauce that comes from Lisp as macros and reader macros.


This doesn't make Python any more functional, all it does is change the syntax.


Python is already functional enough, it's the brain behind the keyboard wasn't that much functional before ( that was me )


Imho it lacks good types. Python with the clojure collections as default types would be awesome.


Okay, well at least you can add a proper distinction between variable binding and assignment (let vs. set!) if you have macros, but that doesn't really make it more functional, just better.


Well, you could implement proper distinction. let and setv both compile to setattr() in the current scope right now.


How about "HAI" -- a Lisp that compiles to Lolcode?


Most of the programming language Y to language Z requires the user to know more Z than Y. Kind of losing the point there.

Everything's not only about making points, but still...


For a Lisp fan, merely learning another language is fine. It's the need to actually use that other language day to day that creates a lot of obvious wasted repetitive effort and friction. Without macros, much of what the software industry produces is essentially macro expansions done by hand (sometimes called "plumbing" or "infrastructure").


Hy was originally a project to show "Hey, see how awesome Python & AST is!". Lisp being an easy choice to implement. Just awesome it have turned into something actually use able and fun to code with.


One use for such a thing I can think of is to use it as a reference for teaching basic parsing techniques. E.g. have a project for an undergrad course where they learn how traditional recursive descent parsing works, and then they get to implement an s-expression parser (possibly to a simplified version of the python AST).


[deleted]


Give me a fucking break, neutering language because somebody somewhere might hypothetically be emotionally damaged by reading it is something that we can save for marketers writing bone-dry press releases. If you don't like that word, then you don't have to say it. Pestering other people for saying it is a joke.

Why don't you go submit pull requests to every single fucking project using the WTFPL license while you are at it?


People can complain about anything they want, just like you are, and his comment about a preferred norm doesn't constitute pestering any more than yours does.


It's not the same at all. Someone initiating an offtopic kerfuffle in a public forum is inviting responses. Hopefully the author's deletion spree was lightbulb and not just karma preservation.


[deleted]


It is an easy concept to grasp. The way you presented it was insufferable, and I'm fairly certain you did have a comment moaning about downvotes.


What was the original (now deleted) comment about?


It seems like someone is offended by the use of the word ___damn in the readme (censoring myself here so I don't offend them, I guess).

https://github.com/hylang/hy/pull/499


[deleted]


What does it mean to say that you were "offended" by it? What sort of emotion did it elicit?

It's a word that you don't say, I get that, but how do you make the jump from "I must not say this word" to "I am disturbed in some way when I encounter somebody else who does not share my religious taboo"?

I don't think you actually make that jump, if you reflect on what you actually think and feel about this.


[deleted]


If you don't like it, then don't say it. If the existence of people who do not share your religious beliefs honestly disturbs you, then you have some serious problems.

Frankly, I don't believe you. If being made aware of people who do not share your religious convictions, both in style and magnitude, really effected you in a negative way, then you would be in a non-functioning emotional tizzy 24/7 unless you were living isolated away on a compound or something. No, there is no genuine emotional damage here, nothing but a purely academic notion of "offense".

Just another opportunity for cultural imperialism. Yet another failure to recognize that religious rules should not be imposed on others, and are only acceptable in modern society when applied to yourself.


And somehow we've gone from a minor request for the removal of vulgarity to "cultural imperialism". Sheesh.


He is asking that others abide by the rules and regulations of his religion. What do you think that I should call it?


Dude, it's marketing. If you want to promote your language, don't make it offend people. It doesn't matter if the offense holds up to your personal views on what should and shouldn't be offensive.


[deleted]


> "I don't say things that I know are offensive to you."

I ask for nothing of the sort. You may behave how you wish, but don't expect others to mime you in return as a favour to you.

Your religious rules are your religious rules. They are accepted "common decency". We certainly do not have them in common.


Ages ago, there used to be a python-lisp hybrid called e7. I wonder if that provided any inspiration.


Has there been any work done on Light Table integration?


I have been trying to pull-off a nREPL for hy. But haven't really come close yet. Going to try and do some more work on that front in the near future.


Why the non-tsandard names of everything? And... CLOS?


What is the standard you're talking about? Common Lisp? Scheme? Clojure? Emacs Lisp?

Hy looks like it borrows heavily from Clojure, which borrows from Common Lisp in terms of names, but they are both different languages and so they differ. About the only objectionable name I found in Hy is `assoc`, which I'd expect to return the value with given key and not set it.

And CLOS is quite a good object system, actually. I somehow missed how it's implemented in Hy, but multiple dispatch would be cute in Python.


    What is the standard you're talking about? Common Lisp? Scheme? Clojure? Emacs Lisp?
Common Lisp, of course. That's what you refer to when you say Lisp today. Otherwise you'd say Scheme, Clojure or Elisp.

    And CLOS is quite a good object system, actually.
Yes, I agree -- my comment was referring to the fact that it is missing from Hy.


[deleted]


Can someone explain for non-native English speakers what’s the problem with “goddamn”?


Some people who are members of Abrahamic religions (Christianity, Islam, Judaism, Mormonism, etc), interpret the (2nd or 3rd Commandment, depending on how you are counting) "shall not take the lords name in vain" thing to imply that you must not say the word "god" (You will frequently see 'g-d' used by these people). Others see it as a prohibition against using the word "god" irreverently. Others see it as a prohibition against using the word "god" when combined with other "swear words" (this is the "goddamn" case, "damn" being an extremely mild "swear word" that can be found in PG movies). Others still go further and say that the commandment forbids the use of 'minced oaths', such as 'heck' (hell), 'darn' or 'dang' (damn), 'gosh' (god).

For the most part, everybody considers this restriction something that they should only expect of themselves (very similar to how it is unheard of for a Jewish or Muslim person in America to object to somebody else eating pork). Rarely, you encounter somebody who does not have a strong grasp on that concept.


Incidentally, there is yet another interpretation of "taking the Lord's name in vain"[1] to mean "to speak as if you have the authority of God."

Some people seem to believe that certain words, by their nature, have different power than other words of equivalent meaning. So you see this sanctimonious abolition of "cursing", where it's okay to say "darn" instead of "damn" and "butt" instead of "ass" and "I am displeased" instead of "this is fucking bullshit".

So this notion of "taking the Lord's name in vain" must mean something else. A little study of context tells us that many shamans and prophets and priests of various religions would "invoke" the name of their god when making decrees to lend authority to their statements.

Which doesn't work if you're trying to prove out the legitimacy of God. Whomever wrote The Bible understood some things about logic[2]. He knew that appeal to authority was a logical fallacy, and thus much of the judeochristian system is predicated on the personal relationship between man and God and the dangers of overtrusting Church leadership. "The devil will quote scripture to you."

And intent matters. If you say "it's a pleasure to meet you" with your jaw and fists clenched, you probably don't really mean it, and are basically telling a lie. A poor lie, but a lie nonetheless. Does saying "gosh darnit" really make a difference to an omnipotent and omniscient being such as God? I think He would know that you meant, "God fucking dammit all to burning hell in a whore's handbasket"[3].

Because one must understand the reasoning behind God's laws. It doesn't matter if you literally pushed the knife into a man's heart or just arranged for it to happen that someone else kill the man, you killed the man. To follow the letter of the law but not the spirit of the law is duplicitous, dishonest. This sort of behavior is held up throughout the Bible as that of the "Gentiles", the non-Jews who mince the Lord's law.

So this is where the prohibition against "taking the Lord's name in vain" comes in. It's about "do not deign to speak for God." And with that understanding, it becomes clear that it is the people who say, "you shouldn't say Goddammit, it's offensive to God" are the ones who are committing said sin in the first place.

So yeah, fuck em.[4]

[1] If you don't already, for a moment, assume the existence of the judeochristian God, if only to allow for me an easier writing job. It is not meant as an assumption that you believe in such things.

[2] emphasis on some.

[3] for example.

[4] okay, you may revert to your regularly schedule religion now.


I was under the impression that this was considered the proper interpretation by theologians. The common interpretation was the same type of common wisdom as the belief that "god helps those who help themselves" is in the bible. This seemed obvious when I was a child and cared about these things anyway.

But goddamn, I had never put together the fact that 'it is the people who say, "you shouldn't say Goddammit, it's offensive to God" are the ones who are committing said sin in the first place'. That's an excellent observation, thank you. The rest of it's well explained as well.


Yep. And it's the interpretation preferred by a lot of us non-theologian-but-believing-and-thinking Christians too. Alas, not the vocal ones who get on TV. I find it more 'offensive' that politicians invoke God's name to promote nationalism and wars that if someone says 'goddamn' or 'oh my God' or whatever. (Don't even get me started on that evil bullshit from the "Westborro Baptist" cult - that is extremely offensive to me as a Christian. That is /seriously/ using God's name in vain.)

I was somewhat under the impression that a lot of the insane over-zealous legalism of 'modern' protestant Christianity was at least somewhat since the Victorian era. A lot of European countries (not the UK) have a much more realistic approach to 'cusswords' and 'swearwords' and so on.

Looking at many past theologians (Martin Luther, for obvious instance), you find that there was much less of an insistence of 'clean' language. We live in a dirty, messed up, stinking world. Sometimes it's appropriate to use words that reflect that. What we're called to do is help to make that world less filthy, and help heal the broken people. The words we use, although not irrelevant, are certainly of much less importance that contemporary religion seems to think.

The bible itself has a couple of instances of 'foul' language, actually. English translations normally tone it down for their audiences... Which is kind of ironic, since most of it was written originally for non-priggish earthy real people, who spoke in street language, not in high class ecclestiatical nonsense (the New Testement is in Koine (common) greek, not in formal classical Greek.).


Ok, but even in that interpretation, saying "god damn it" is "god should send that thing to hell", which doesn't seem like it should be said lightly, and, um, treads close to speaking for him.


Saying it lightly clearly means you don't really mean it. You're not literally trying to convince someone that God is going to damn them. As I said, I would think a supposedly omniscient God would know the difference.


It's considered profane.

Television in the United States is okay with the word 'damn', but there are people who consider the combined use with 'God' to be disrespectful to the word 'God' (and believers), stemming from the belief that many religions have that 'God' (and other synonyms) should be reserved for when a person is addressing that deity. Also, many believers consider it a faux pas to impose on the deity of their chosen religion. (Goddamn, meaning "God, please damn .." is issuing a direct command rather than asking for an assistance)

This means that often times on television the word 'Goddamn' has 'God' bleeped from it, to form 'Bleeep-damn', which is okay, apparently.

(Apparently it's not disrespectful to overwrite the deity's name/title with an obnoxious noise)


If I start a religion where god is named, "bleep" can I get it covered with "God" instead?


You've got my vote.


Some people believe in magic, i.e. the ability of words to have power over their environment completely separate from the bare meaning of them.


Apparently, Hy is the favoured Python-targeting Lisp dialect of the Great Adversary.

(Which piques my interest.)


Yeah, it's probably not the best idea. Looks like someone opened a pull request to fix it: https://github.com/hylang/hy/pull/499




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: