HNHacker News
TopNewBestAskShowJobs

Kodiologist

292 karma · joined May 3, 2022

http://arfer.net
submissionscomments
Kodiologist··on Google.com search now refusing to search for FF esr 128 without JavaScript
I got it to work again with a user agent from Links: `Links (2.29; Linux 6.11.0-13-generic x86_64; GNU C 13.2; text)`.
Kodiologist··on Hy 1.0 – Lisp dialect for Python
Admittedly, I've tried not to document the implementation. Yeah, they're pretty much simple dirty Common Lisp macros. Internally, they're functions that are called with the arguments converted to models (via `hy.as-model`), and then the return value is converted to a model. If a macro's first parameter is named `_hy_compiler`, it gets access to the current compiler object; this is undocumented since it's only meant for internal use. Reader macros have no parameters, but can access the current reader object as `&reader`. When it's defined, a reader macro is added to the current reader's dispatch table.
Kodiologist··on Hy 1.0 – Lisp dialect for Python
Yeah, at a certain point I realized that both the maintenance and the use of the language became much slicker if unnecessary deviations from Python were minimized. After all, when I'm writing Hy code, I'm usually spending a lot more time referring to the documentation of Python or third-party Python libraries than the documentation of Hy. I felt there were a number of ways Python could be improved upon, but e.g. the old feature that let you spell `True` as `true` in deference to Clojure was just a needless complication.
Kodiologist··on Hy 1.0 – Lisp dialect for Python
You can add all the same type annotations as in Python, but from what I've seen, type-checkers expect Python source text and don't just use standard Python introspection, so you'll need to use `hy2py` first to actually check your program's types.
Kodiologist··on Hy 1.0 – Lisp dialect for Python
You're welcome. There are no actual breaking changes from 0.29.0, so you're already up to date if you got that far.
Kodiologist··on Hy 1.0 – Lisp dialect for Python
Yes, such as: metaprogramming via macros and reader macros; arbitrary compile-time computation; removal of restrictions on mixing statements and expressions; and other arities for Python's binary operators. See http://hylang.org/hy/doc/v1.0.0/whyhy#hy-versus-python

Dynamically shadowing global variables is not built-in, but easy to write a macro for if you want it. See e.g. https://stackoverflow.com/a/71618732

Kodiologist··on Hy 1.0 – Lisp dialect for Python
Sparse? I got a whole chapter for ya: https://hylang.org/hy/doc/v1.0.0/macros
Kodiologist··on Hy 1.0 – Lisp dialect for Python
Learning Python is not required to get started and do some simple stuff, but it is effectively required to master Hy.
Kodiologist··on Hy 1.0 – Lisp dialect for Python
Hy-pothetically, yes, you could take Hy code in and spit Python code out via `hy2py`. I think at one point I considered supporting this officially, but then decided there was really no advantage.
Kodiologist··on Hy 1.0 – Lisp dialect for Python
Now I know how those guys felt who were on the same episode of Ed Sullivan that introduced the Beatles.
Kodiologist··on Hy 1.0 – Lisp dialect for Python
I don't think so? https://youtrack.jetbrains.com/issue/PY-48754/Support-for-hy...
Kodiologist··on Hy 1.0 – Lisp dialect for Python
Thanks. I enjoyed compiling a huge list of buzzwords to use for it.
Kodiologist··on Hy 1.0 – Lisp dialect for Python
I see. That's pretty similar to the feature set of [pdb](https://docs.python.org/3/library/pdb.html). You may then logically ask "Does Hy support pdb?". The answer is "sort of". I've fixed one or two bugs, but we don't test it. I suspect there are various features of pdb that assume Python syntax and would need some hooks to get working properly with Hy.
Kodiologist··on Hy 1.0 – Lisp dialect for Python
1. I don't know what a breakloop is. Hy uses Python's exception system, which is more like a traditional exception system than Common Lisp's condition system.

2. No, sorry.

Kodiologist··on Hy 1.0 – Lisp dialect for Python
> Are there Python language features I can't use in Hy?

At the semantic level, no. I work to cover 100% of Python AST node types with Hy's core macros. It does take me a little bit to implement a new core macro after the CPython guys implement a new feature, but you can always use the `py` or `pys` macros to embed the Python you need, should it come to that.

> Or performance penalties in using Hy?

Compiling Hy (that is, translating it to Python AST) can be slow for large programs (I've seen it top out at about 3 seconds), but at runtime you shouldn't see a difference. Hy always produces bytecode, which can be used to skip the compilation step if the code is unchanged.

Kodiologist··on Hy 1.0 – Lisp dialect for Python
> this compiler is written in Python

Yes, that's right. Hy is not self-hosted.

> The various ways you can embed a Lisp look very different and have very different tradeoffs.

Hy itself provides options. Typically the process is that the Hy source code becomes Python AST objects, which Python then complies and executes, but you can also translate the Python AST objects into Python source text. Or you can use Python from Hy or vice versa: https://hylang.org/hy/doc/v1.0.0/interop

Kodiologist··on Hy 1.0 – Lisp dialect for Python
I eliminated a lot of whimsy from Hy and its documentation years ago because it was distracting and created noisy test failures, but I did go too far at some point, and have tried to reintroduce a little whimsy more recently.
Kodiologist··on Hy 1.0 – Lisp dialect for Python
I'm not sure. I was going to say that Mojo is proprietary software and so I've never tried it, but I just checked and apparently it's free now. If nothing else, you can probably get a lot of Hy code to run on Mojo via `hy2py`, if Mojo supports a lot of Python as it claims to.

Edit: actually, confusingly, the GitHub repository for Mojo doesn't have an interpreter. The language is still proprietary.

Kodiologist··on Hy 1.0 – Lisp dialect for Python
Well, this is a little embarrassing: Clojure was one of the biggest influences on Hy in its youth, but that was mostly before I got involved in 2016. I never actually learned Clojure. So hopefully somebody who knows both Hy and Clojure well can answer. I can tell you that at run-time, Hy is essentially Python code, so Hy is more tightly coupled to Python than Clojure is to Java; a better analogy is CoffeeScript's relationship with JavaScript.

I get the impression that Clojure tries to convince the programmer to avoid side-effects a lot more strenuously than Hy does, but it's still not a purely functional language, so I don't know how consequential that is in practice.

Kodiologist··on Hy 1.0 – Lisp dialect for Python
Remarkably enough, yes, we got it to work, on our 3rd or 4th try.
Kodiologist··on Hy 1.0 – Lisp dialect for Python
The author of the e-book is a different guy, Mark Watson. He isn't involved in the development of the language.
Kodiologist··on Introduction to Calvin and Hobbes: Sunday Pages 1985-1995 (2001)
No, actually, although you could argue that the word "retire" isn't applied quite correctly in such cases. It's common for academics, for example, to continue doing much of the same work once they're nominally retired, just at a different pace with different priorities.
Kodiologist··on Homoiconic Python
Hy slower than Python? It shouldn't be, at least at run-time. I maintain Hy. If you notice any meaningful performance differences, that's a bug.
Kodiologist··on Hissp
As the Hy maintainer, I'd say that assessment is pretty accurate, at least on the Hy side.
Kodiologist··on Why Hy?
In Hy, you can include Python with `py`, as in

    (py "(-b + sqrt(b*b - 4*a*c))/(2*a)")
Kodiologist··on Why Hy?
1. Nope, sorry.

2. That's right. Hy depends much more on finicky details of Python than most Python packages do, particularly Python's AST, so each 3.x release of Python usually requires some changes to Hy to support it. Each Hy release supports (at least) all versions of Python 3.x that have been fully released and are not yet at end of life.

3. More precisely, we're trying to take more of our conventions from Python rather than Clojure. See https://news.ycombinator.com/item?id=31250992

Kodiologist··on Why Hy?
Cool, I'm a Hy guy; glad to meet you. Hy in its early years imitated Clojure syntax much more closely, and Clojure compatibility may've been implicitly a goal even if it never got to the point of cross-testing. These days we prefer to think of Clojure as one of several possible influences.
Kodiologist··on Why Hy?
I've been trying to steer the syntax towards imitating Python more than Clojure, the idea being that you frequently need to rapidly switch between reading Python and Hy (as when you're writing a Hy program while consulting documentation for a Python library), so it helps to minimize friction there. Thus e.g. `True` must now be capitalized that way, Python-style; `true` used to be allowed as well. But whether a more Pythonesque Hy is more or less confusing than a more Clojuresque Hy is admittedly a matter of taste.
Kodiologist··on Why Hy?
I've been working on Hy since 2016 and I've frequently encountered, but never understood, the sentiment that Hy isn't a "real Lisp". What makes for a real Lisp? There have been dozens (hundreds?) of Lisps over the decades, and if they all have a defining characteristic that Hy lacks, I don't know what it is. Certainly Lisps have varied in how scoping works, among other things.
Kodiologist··on Why Hy?
I'm not familiar with Jupyter internals, but I think functions would work well for this. Hy allows multi-statement anonymous functions, and you can do stuff like `((fn [] … ))` to define and immediately call the function. One advantage of this over `let` is that it allows old locals to be garbage-collected. If memory isn't an issue, though, `let` should work well.
Page 1 of 2Next →