
Hy - tosh
https://en.wikipedia.org/wiki/Hy
======
pixelmonkey
hy was first introduced to me at PyCon 2013 in a lightning talk by @paultag,
the language's creator. It was a _very_ fun lightning talk. You can still
watch it online here:

[https://youtu.be/1vui-LupKJI?t=968](https://youtu.be/1vui-LupKJI?t=968)

I remember that day pretty clearly because in the same lightning talk session,
Solomon Hykes introduced the Python community to docker, while still working
on dotCloud. This is what I think might have been the earliest public and
recorded tech talk on the subject.

[https://youtu.be/1vui-LupKJI?t=1579](https://youtu.be/1vui-LupKJI?t=1579)

This was also the same PyCon that Eben Upton opened with a keynote to discuss
the mission of Raspberry Pi, while also announcing that each of the 2,500
attendees would receive a free physical Raspberry Pi at the conference.

It was a pretty darn good year of PyCon; 2013 was apparently a good vintage
for open source tech with Python connections.

~~~
parentheses
He (author of Hy) is quite entertaining.

~~~
octetta
Had the good fortune to work with Paul briefly. He's not only smart, but he's
a heck of a nice guy.

------
dang
Many previous threads; some of the larger ones:

2017
[https://news.ycombinator.com/item?id=14909786](https://news.ycombinator.com/item?id=14909786)

2014
[https://news.ycombinator.com/item?id=8696975](https://news.ycombinator.com/item?id=8696975)

2014
[https://news.ycombinator.com/item?id=7214400](https://news.ycombinator.com/item?id=7214400)

2013
[https://news.ycombinator.com/item?id=6700103](https://news.ycombinator.com/item?id=6700103)

2013
[https://news.ycombinator.com/item?id=5924709](https://news.ycombinator.com/item?id=5924709)

------
cutler
If Hy could resolve its problems with let being moved to contrib and attracted
enough manpower to reach 1.0 I think it could attract significant mindshare.
Hy fills in the missing piece for devs who want to go all-in with modern Lisp
supported by an established ecosystem, ie. front-end/Clojurescript/NPM,
scripting/Hy/PyPi and back-end/Clojure/JVM.

~~~
mark_l_watson
I agree that removing ‘let’ makes the language much less pleasing for me to
use. I recently looked in contrib for ‘let’ and saw the macro definitions but
could not get it working. It seems like a small thing, but it does keep me
from doing more than rare experiments with Hy.

~~~
nerdponx
Curious what problems you had with let. I tried it recently and it worked
fine. Having an import is annoying but it's not the end of the world.

~~~
rcarmo
It was removed without the replacement macro being fully baked, and a number
of other things were changed at the same time. Rather than rewrite my stuff at
every minor release, I moved on.

~~~
nerdponx
That's what I'm asking. What's not fully baked about it? In my (admittedly
small) testing, it does its job of assigning stuff in a temporary scope.

~~~
reikonomusha
I haven’t tried, but are the variables properly captured in closures? LET
should have “temporary” lexical scope, not “temporary” temporal/dynamic scope.

~~~
gilch
It does at least act like it has closures. Try starting the REPL with $ hy
--spy and you can see how examples get compiled.

------
vindarel
Hy made me reconsider Lisps and I'm glad it did. I'm now using CL quite a lot.
It's possible to use Python libraries from CL:

\- there is py4cl and async-process: [https://github.com/CodyReichert/awesome-
cl#python](https://github.com/CodyReichert/awesome-cl#python)

\- NumCL is a clone of Numpy:
[https://github.com/numcl/numcl](https://github.com/numcl/numcl)

Common Lisp has many advantages though:

\- you can build a self-contained binary of your app, including web app. It's
such a breeze to deploy, and it's possible to ship a binary to users.

\- the REPL is much better and more fun than ipython

\- CL is compiled. We compile our code _function by function_ , and we get
many compiler warnings at compile time.

\- CL is stable, the syntax is simple, you can add the syntax you want with
extensions (decorators, string interpolation,…) and yet, the implementations
keep improving, and new ones are created (Claps, CL on LLVM).

\- CL is fast (how pgloader got rewritten from Python to CL:
[https://tapoueh.org/blog/2014/05/why-is-pgloader-so-much-
fas...](https://tapoueh.org/blog/2014/05/why-is-pgloader-so-much-faster/))

\- there may be more libraries than you think:
[https://github.com/CodyReichert/awesome-
cl](https://github.com/CodyReichert/awesome-cl)

\- the object system is very nice, the multiple dispatch makes me have a
cleaner and shorter ABI of my app.

\- there are more editors with good support than Emacs: Atom support is
getting very good, and there's more: [https://lispcookbook.github.io/cl-
cookbook/editor-support.ht...](https://lispcookbook.github.io/cl-
cookbook/editor-support.html)

\- the (default) package management system works with "distributions", à la
apt/Debian, so it doesn't break suddenly because of a third party of a third
party dependency.

Of course, the web stack is less mature (but more promising: see Weblocks
[http://40ants.com/weblocks/](http://40ants.com/weblocks/)) and CL might be
more difficult. It's not for every one. But it's been a joy so far.

------
AdamSC1
Anyone got an ELI5 on the goal of this language, or the pros and cons?

I'm not a dev, but, a Python user with a background in data/info science - so
I'm a bit unclear on what Wikipedia means by things like "a dialect language
of Lisp", and using it to write "domain specific languages."

Is this just a way to use Python libraries in Lisp (which seems to be a low
level programming language?)

~~~
jnbiche
Lisp is not typically a low-level programming language, but rather extremely
high-level (high level of abstraction)[0].

The "dialect language of Lisp" quote just means that it's a variation of Lisp,
but running in a Python environment.

The term "domain-specific languages" refers to programming languages created
for a specific, often one-of, task. If you look at this repo, you'll see
various languages used to create diagrams and graphs in this library. These
are all examples of DSLs (note, they're in many places, this is just an
example):

[https://github.com/francoislaberge/diagrams](https://github.com/francoislaberge/diagrams)

Regarding Hy specifically, it's basically Python that uses a different syntax,
or skin, of sorts. Instead of white-spaces and colons, you get parentheses
and...parentheses. It's more complex than that, but it's basically just a way
to write Python for people that like Lisps.

0\. Yes, there are some examples of low-level lisps without features like
memory management, but they're pretty unusual.

~~~
alexanderdmitri
How does Hy manage recursion given the limitations there in Python?

~~~
gilch
It doesn't. Or does the same way as Python: imperative loops. TCO is a key
feature of Scheme, but not of Lisps in general. Clojure doesn't have it. You
can always trampoline like Clojure's loop does.

~~~
alexanderdmitri
10-4, thank you!

------
tosh
related: a story on Hy popped up on hacker news a few days ago [0][1]

but didn't get much attention at the time:

    
    
      """
      BETTER IS BETTER THAN WORSE:
      TALES OF A WEEK WITH HY AND A CALL FOR REVOLUTION
      by "Mr. Mojo Rising"
      """
    

I put it into nextjournal for easier reading:

[https://nextjournal.com/tosh/better-is-better-than-
worse](https://nextjournal.com/tosh/better-is-better-than-worse)

\--

[0]
[https://0bin.net/paste/xmJWIlIv+Ws+Fbjs#zCyc4Yc4T+YISv3MHwMT...](https://0bin.net/paste/xmJWIlIv+Ws+Fbjs#zCyc4Yc4T+YISv3MHwMTwScu0as4xzqjns9YKaw1v1k)

[1]
[https://hn.algolia.com/?query=hy%200bin.net&sort=byPopularit...](https://hn.algolia.com/?query=hy%200bin.net&sort=byPopularity&prefix&page=0&dateRange=all&type=story)

~~~
StavrosK
Huh, I love this guy's writing style, thanks for the link.

------
billfruit
I tried it out some time ago, but my view is that is too similar to clojure
but also different in significant ways, making it a pain to remember the
differences if you also happened to be working on clojure code. Being too
similar but not the same can cause problems with programming language syntax.

------
karmakaze
TI(also)L:

Kawa [Polish for coffee] is a language framework written in the programming
language Java that implements the programming language Scheme, a dialect of
Lisp, and can be used to implement other languages to run on the Java virtual
machine (JVM). It is a part of the GNU Project.

[https://en.wikipedia.org/wiki/Kawa_(Scheme_implementation)](https://en.wikipedia.org/wiki/Kawa_\(Scheme_implementation\))

~~~
cercatrova
Interesting. Why not use Clojure which runs on the JVM?

~~~
karmakaze
I've used both Clojure and Scheme (lazy racket) and find them both
interesting. The part about Kawa that's novel is that it can be used to make
other languages that run on the JVM.

------
vincent-toups
I'm a long time Lisper and Hy makes Python just tolerable enough to use as a
data scientist. It can't or doesn't want to solve Python's worst problems, but
its a big improvement.

~~~
ausbah
What are Pythons biggest issues from your perspective?

~~~
vincent-toups
Scope and type weirdness and just general lackadaisical design philosophy.
Hostility towards functional programming. Its also still really really slow,
particularly in this era of JIT languages like Lua.

Also, I generally find the libraries to be amateurishly designed. Big one that
comes to mind is Pandas.

------
akhong
DNS error for the docs [http://docs.hylang.org/](http://docs.hylang.org/) :/

~~~
zdkl
Not sure if it's quite the same thing, but this is still up
[https://hy.readthedocs.io/en/stable/](https://hy.readthedocs.io/en/stable/)

~~~
rmbeard
It shows build status: build failing.

------
owenversteeg
Sounds very interesting! Anyone here who uses (or tried) Hy? I'm curious how
easy it is to use some arbitrary thing in Python (library, code snippet, etc)
in particular.

~~~
rcarmo
I wrote [https://github.com/rcarmo/sushy](https://github.com/rcarmo/sushy) on
it before they moved let to contrib.

(I later ported it back to pure Python 3, because I couldn’t move forward
while Hy was in flux)

If let was “fixed”, I’d probably move back to Hy.

------
tim333
I played around with Hy and found it fun but I'm not sure anyone is using it
for anything serious?

------
mhxion
Cloudflare throws a dns origin error. Repo:
[https://github.com/hylang/hy/blob/master/README.md](https://github.com/hylang/hy/blob/master/README.md)

~~~
jjakque
Ditto, getting `Error 1016` from CloudFlare.

Have to resort with using web archive:
[https://web.archive.org/web/20190714180208/http://docs.hylan...](https://web.archive.org/web/20190714180208/http://docs.hylang.org/en/stable/)

------
mhd
One problem I had with Hy is that some codebases really depend a lot on
annotations, which gets a bit messier in Lisp syntax.

~~~
mistersys
It's a lisp, so you can build your own syntax, the messiness of annotatations
is only limited by your creativity.

    
    
      (defna add [a :: int b :: int] (+ a b))
    

[https://pastebin.com/5kpTBiz2](https://pastebin.com/5kpTBiz2)

You could expand that macro to support decorators as well via extra arguments
before the args list, you'd be in great shape.

------
hodder
WHy? Super cool project, but what would be the purpose of it? Or is it just a
fun project to develop skill?

~~~
vaer-k
Lisps are pretty pleasant to write in, and having metaprogramming support in
your language is a game changer.

------
TazeTSchnitzel
It seems like it is pretty much just Python, but written with s-expressions
and supporting macros.

~~~
lonelappde
The word "just" almost always adds nothing of value makes a sentence less
polite.

~~~
TazeTSchnitzel
I completely agree and try to limit my usage of it. I am using it here to
emphasise that it is only a different syntax for Python and nothing more. That
is not to say that it is not valuable or interesting.

------
fhennig
This is not like the clojure is to java, it's only a syntax transformation,
superficial.

Usually lisp and FP means that you get immutable data structures and a good
concurrency system, both of which you get in clojure.

I looked at this a while ago and figured it's not useful for production, but
an interesting project none the less.

~~~
wirrbel
This is certainly true if you are used to clojure.

But interestingly enough, idiomatic common lisp code can be roughly play in
the same field as Python in terms of "purity". Also, lot's of scheme code is
almost imperative in nature, if you look at it from the perspective of a
Clojure or Haskell programmer. This is why Paul Graham once gave the advice to
use Python if you cannot use Common Lisp.

I think Richard P. Gabriel wrote a "complaint" about functional programming
being redefined by the research/types/ML crowd (he wasn't so much complaining
about them striving for purer FP, but for taking over the conferences, etc.
driving out the more traditional FP traditions from the lisp communities).

Anyways, what I wanted to say is: FP is fairly broad as a topic, a lot can
fall under it or out of it depending where you draw the line. That's not a bad
thing and there is space for mutable lisps.

The other aspect is: If you have Python, there is not much to gain from
s-expressions alone. sure you get macros, but otherwise you already have a lot
of the benefits you get from Lisp over let's say C++ (dynamic typing).

~~~
fhennig
Interesting; functional programming was introduced to me through dr. racket
scheme, and the core concept in there was that there is no mutable state. To
me, having mutable state makes it imperative, you're not evaluating
functions/expressions, you're executing statements that modify a state.

~~~
cygx
As I see it, there are two orthogonal roots to functional programming:
Mathematical functions on the one hand, and lambda expressions/closure/higher-
order functions/... on the other.

The former implies immutability and technically belongs to the declarative
side of things: A mathematical function declares a relation between input and
output, but I say technically because functional code can read rather
algorithmic.

The latter can be added to imperative languages that do feature mutable state.
Depending on the language, I might still classify it as functional, but
impure.

~~~
wirrbel
yeah, I'd say its quite simple. there is "Functional programming", and it is
an umbrella term. Then there is "purely functional programming" and it's kind
of better defined than it's hypernym. For purely functional programming we are
certain that we want to be immutable, try to limit the usage of effects.

Lately, I think, there is even a de-emphasis in _functions_ as the base of
(purely) functional programming. What's now beimg emphasized is the
composability-aspect. Functions are an abstraction that is composable, but so
are other abstractions.

------
bhougland
The Jupiter notebook kernel seems to be broken for it right now.

~~~
gilch
Which one is broken? There were at least two, last I checked:

* [https://github.com/bollwyvl/hy_kernel/](https://github.com/bollwyvl/hy_kernel/)

* [https://github.com/Calysto/calysto_hy](https://github.com/Calysto/calysto_hy)

------
amirouche
Does it support syntax-rules or something similar?

~~~
gilch
It has defmacro.

------
rmbeard
DNS error for me as well.

------
foobar_
Lisp with the most amount of libraries.

------
mruts
Does the language support macros? If not, it’s totally worthless. Python is a
pretty bad language for even casual FP, and a S-exp syntax layer isn’t going
to help.

~~~
tmountain
_ If not, it’s totally worthless._

Kind of a harsh assessment don't you think? Maybe some people enjoy working in
Lisp-like languages while also enjoying Python's huge ecosystem of libraries.
I doubt it's worthless for those folks.

~~~
mruts
No one actually likes the parens of Lisp. I mean, just look at Racket2. Even
the dedicated lispers who work on Racket think they suck.

I’ve written both Racket and Common Lisp professionally and consider myself
very competent in both. In fact, I think they’re both great languages and one
of the best around.

It’s not because of the parens though, it’s because what the parens give you:
namely homoiconicity and easy macros.

Without these things, the increased syntax burden of parens don’t buy you
anything except visual noise and being forced to type extra characters.

~~~
sls
> Without these things, the increased syntax burden of parens don’t buy you
> anything except visual noise and being forced to type extra characters

So instead of f(x), I have to accept the visual noise and extra characters of
(f x)?

~~~
cat199
> So instead of f(x), I have to accept the visual noise and extra characters
> of (f x)?

(f x) and f(x) have the exact same number of characters; one mans'visual
noise' is another's 'visual clarity'

~~~
mruts
What about (+ (/ 1 2) 5) and 1/2 + 5?

Also if you think parens and prefix notation are so great, would you also like
to see math papers written that way?

~~~
kazinator
Now you have to know that 1 / 2+5 is still (1/2) + 5.

The S-exp can be shortened in anything calling itself a Lisp, using the unary
reciprocal: (+ (/ 2) 5).

Math papers are full of obscure notations; they should standardize on s-exps.
Then just a straightforward dictionary of symbols would be needed to look up a
notation.

Math notation is at least 2D: it makes good use of spatial structures to
reduce ambiguity. For instance, instead of inventing some crazy ternary
operator, mathematicians will just arrange three arguments spatially around a
symbol. The space subdivides recursively, so elements end up being
positionally determined, somewhat like what S-exps do in 1D.

~~~
mruts
I can format equations in latex in fewer characters than I could express in
Lisp, so what you’re saying about 2D vs 1D really doesn’t make any sense.

~~~
kazinator
LaTeX is (understandably) geared toward single-character variable names, and
provides canned control sequences for common functions like \sin \cos. Try it
with variable names that are two or more characters, and user-defined
functions.

------
qwsxyh
I genuinely fail to understand the advantages of any sort of Lisp. Contrary to
what gigantic brain lisp devs might think, it's syntactical annoyingness is
far too much of a barrier to overcome.

~~~
BeetleB
>it's syntactical annoyingness is far too much of a barrier to overcome.

You're likely being downvoted because statements like these are more a
reflection of you than the language, but instead of phrasing it that way, you
come across as making an absolute statement about the language.

In any case, I'll bit.

I'm not a Lisp programmer - the extent to which I do Lisp is the occasional
Emacs Lisp. Still:

You can use virtually any character as part of your variable name. Lispers
tend to use hyphen and '?' a lot. Once you get used to it, it's hard not to
view all other languages as inferior. Why did they restrict the variable names
so much?

A lot more substantive: I saw this in John Kitchn's blog post somewhere. My
details are probably a bit off, but I think I have the general gist of it. His
team works on, I believe, computational chemistry. Their code base is in
Python, and they've developed an API for various aspects of their calculation.
A lot of their functions require a lot of arguments - not generally a good
idea, but it makes sense in the domain they work in. To manage that headache,
they've built a systematic way of documenting all those arguments in their
docstring, with a particular format.

Unfortunately, that means anyone in his team who creates such a function needs
to conform to that format, and people get lazy, make mistakes, etc.

So using Hy, he wrote a macro for another syntax for defining a function. With
this new way of defining a function, there was special syntax for all the
special information that needs to be in the docstring. The macro then creates
the Python function with the appropriately written docstring. If the
programmer makes a mistake, the macro fails. So now everyone uses the macro to
create those types of functions.

I don't recall the details, but let's say it was something like:

    
    
        deff func(x, x_doc="doc for x", y, y_doc="doc for y",...)
    

If someone makes an argument called x, but does not provide x_doc, then it
will fail.

(I think in reality it was more than that - not just x_doc but x_doc_a,
x_doc_b, etc and it generated the docstring from all those pieces).

Now are there other, perhaps Pythonic ways to do this? Probably. However, it
is nice that for a domain specific problem, you can just invent new syntax and
use it.

~~~
qwsxyh
> You're likely being downvoted

I do not care about downvotes on here.

> You can use virtually any character as part of your variable name. Lispers

This is not a good thing.

> However, it is nice that for a domain specific problem, you can just invent
> new syntax and use it.

This is equally not a good thing.

~~~
kortex
Readability trumps just about all else in software dev, so I am 100% with you
there on variable name limits and lack of syntax extension.

```[a-zA-Z_][a-zA-Z0-9_]*``` is such a universal and useful convention that I
find myself using it even when the domain allows other characters (bash, Xnix
filenames). Obviously this is English-centric so I would include other
language constructs if I were in a country with another dominant language.

In fact even though I have the ability (languages supporting unicode and a QMK
keyboard) to use symbols, e.g. Greek letters for math, I don't, because I know
it's a hassle for anyone else.

> You can use virtually any character as part of your variable name.

> invent new syntax

are a hassle and anti-pattern for the same reason.

~~~
reikonomusha
I think you think all this stuff is bad because you’re imagining having this
power in C or JavaScript, in which case these features would be awful.

However if these features are exposed through clean abstractions in a language
that is syntactically bare to begin with, you might have different thoughts.

------
baalimago
W-Hy?

------
_def
Cuddles the cuttlefish <3

------
vzaliva
Let's combine things the many people hate: lisp parenthesis with python's GIL.
:)

~~~
stefco_
Some of us really like the parentheses!

~~~
vzaliva
I personally like parentheses. But a surprising amount of my engineering
friends bring it up as a major issue as soon as we start talking about List or
Scheme.

------
Reason077
The disturbing logo really puts me off wanting to learn more about this
language.

~~~
ComputerGuru
Am I missing something? It seems it's just a "cute" octopus.

~~~
Foxboron
Funny enough, Cuttles is created by Karen Rustad. She also drew the Ferris
logo for Rust.

