News for hackers. Stuff that matters.
Re:Hy – A Lisp-flavored Python by asimjalis on Wednesday August 02, 2017 @01:29PM (#14912693)
I have been using Hy as an alternative to Python. It is delightful to use. Highly recommended.
Re:Hy – A Lisp-flavored Python by JadeNB on Thursday August 03, 2017 @04:13PM (#14923366)
> using Hy …. Highly recommended.

I think that you are not getting in the proper punning spirit of the language.

Re:Hy – A Lisp-flavored Python by cheez on Wednesday August 02, 2017 @01:45PM (#14912876)
What kind of projects have you used it for?
Re:Hy – A Lisp-flavored Python by rcarmo on Wednesday August 02, 2017 @02:05PM (#14913074)
My blog/wiki engine is written in an older version of Hy:

https://github.com/rcarmo/sushy

I'm currently re-writing it in Python 3.6 because Hy has taken a hard stance in backwards compatibility and deprecated "let" (with a replacement macro, but still) and isn't tackling async (both for understandable, but sad reasons), so it doesn't really work for me anymore.

But while it did, I loved it to bits. Python with a LISP syntax is just wonderful, and if someone ever finds a way to add back the stuff I like, I'm more than willing to deal with the quirks.

Re:Hy – A Lisp-flavored Python by chuckdries on Wednesday August 02, 2017 @02:10PM (#14913130)
I know python, and last semester I took a class that briefly touched (lightly kissed?) LISP for a few weeks. I have a passing familiarity and I really loved the very small amount that I saw. I'd like to learn more, can you go into more detail on the usage of let and how one would go without it?
Re:Hy – A Lisp-flavored Python by flavio81 on Thursday August 03, 2017 @09:25PM (#14925626)
and to directly answer your question, there a are many things you can do with let. Let binds a "form" to a symbol.

    (let ((pi 3.14))
     ... code goes here ... )
So within the "code" part, that is, within that lexical environment, the symbol "pi" exists and is bound to float number 3.14

(Alternatively, you don't need to set a initial value.)

One of the interesting uses of let is that it can also redefine dynamic variables (aka special variables, think of them as "global variables).

So for example let's assume i define timeout to 300, so within my whole package, this special variable has the value of 300. Let's suppose this variable is going to be read by function "my-function", and others.

So i create this special variable:

    (defparameter *timeout* 300)
Now, despite the above, let's suppose i want to call "my-function" but with a timeout of 1000. I can just do this in my code:

    (let ((*timeout* 1000))
         (my-function))
So, inside this "let", when "my-function" gets executed, the timeout will be 1000. Outside of this, it will still be 300.

Let, thus, allows you easy use of lexical environments.

Another use is creating closures by using the combination of "let" with "lambda."

Re:Hy – A Lisp-flavored Python by flavio81 on Thursday August 03, 2017 @09:06PM (#14925536)
> I'd like to learn more, can you go into more detail on the usage of let and how one would go without it?

Welcome to the wonderful world of Lisp.

I'd recommend to you to install Portacle (the Portable Common Lisp Environment), this allows you to code in Lisp straight away.

As for tutorials, "Practical Common Lisp" (free online book) is fun, modern, and excellent for introducing you to most CL concepts, including of course use of let, let*, etc.

Re:Hy – A Lisp-flavored Python by hood_syntax on Wednesday August 02, 2017 @03:37PM (#14913888)
> lightly kissed

How romantic!

Re:Hy – A Lisp-flavored Python by gknoy on Wednesday August 02, 2017 @02:17PM (#14913195)
Thank you for sharing this. The last time I started trying to use Hy, I felt like I was basically writing Python but wrapped in parens -- I felt like I was doing something wrong, but couldn't place what it was, so it's nice to see a non-toy implementation that demonstrates what one can do with it.
Re:Hy – A Lisp-flavored Python by asimjalis on Wednesday August 02, 2017 @03:31PM (#14913818)
My main use cases: Doing data analysis using Numpy, Pandas, sklearn. Calling AWS API using Boto. Calling GDAX API using their Python code samples.

I also use it for small personal scripts.

My first choice for one-off scripts would have been Clojure. But the long startup time for Clojure apps makes it unusable for quick command line scripts. Hy gives us the best of both worlds.

Re:Hy – A Lisp-flavored Python by cutler on Wednesday August 02, 2017 @06:14PM (#14915182)
There's now Lumo - a Clojurescript binary with its own embedded Node.js runtime. Script away!
Re:Hy – A Lisp-flavored Python by elf_m_sternberg on Wednesday August 02, 2017 @03:48PM (#14913977)
There are a few projects on my github (elfsternberg) that I've used Hy for.

One thing that I've also done is write the first draft in Hy, and then used Hy2Py to generate the version that I'm going to publish. This does result in a lot of compiling-by-hand, but the end product is often surprisingly robust.

On the other hand, it's also very (!) un-pythonic. Hy discourages classes in favor of closures, like Scheme, so I end up with a lot of nested sub-functions. My project git-linter looks like that. Hy encourages highly functional thinking, and git-linter is just that: the inputs are things like the configuration file, available linters, the command line, and (depending on the command) either the output of a "git-status --porcelain" or just "find . -type f"; the output is a report on the various outputs of the linters. It's a very straightforward map/reduce/filter, so no object-orientated code at all was required.

To an engrained Pythonista who must make a class for every last step, this land-of-verbs approach tends to look strange.

Re:Hy – A Lisp-flavored Python by kerkeslager on Wednesday August 02, 2017 @08:31PM (#14915970)
I'm not sure I'd call the class explosions that a lot of people are writing these days Pythonic. Lots of older Python code was written with functions and a very occasional class. I think the last decade has seen an upward trend the usage of classes in Python due to the influence of Java and how software engineering is taught in colleges.