11 ms·
Why Hy?
- Qem 5y agoI wish there was a IDLE for Hy (HYDLE?), so one could have a minimum effort environment setup to get started. What editors currently support Hylang syntax highlighting?
- kjuulh 5y agoemacs has a mode for it: https://github.com/hylang/hy-mode https://github.com/hylang/hy-mode doom emacs make it easy to get started.
- seanw444 5y agoWent to install the package manually to try Hy out. Figured it was a niche/small enough language that it wouldn't have its own Doom module. I was wrong.
- mark_l_watson 5y agoI use Emacs and also VSCode. Easy to set up.
- bayesian_horse 5y agoThere is also Calisto Hy and JedHy for Jupyter notebook support.
- oleganza 5y agoWhenever people bring up Lisp syntax, I like to remind everyone about io language. Its homoiconicity is inspired by Lisp, and almost all good things about Lisp syntax are applied in io, but at the same time it avoids this awkwardness that turns away most of the people (and turns the remaining minority into zealots :-) So if you design a language and want to use Lisp-like syntax, I recommend to also check out io before steaming ahead.
- jhbadger 5y agoI played with io some time ago as it was one of the languages covered in Bruce Tate's "Seven Languages in Seven Weeks" which give an introduction to seven programming languages (Ruby, Io, Prolog, Scala, Erlang, Clojure, and Haskell) each with a different philosophy. Io seemed an interesting proof of concept, but are you actually using it for a real project or just to explore?
- cardanome 5y agoYeah, Lisps don't have a monopoly in homoiconicity. In addition to io, the Rebol family is also worth checking out. Though I have to admit I can not imagine how a person can be so mentally inflexible as to be not able to tolerate Lisp-style syntax. I get that Common Lisp might look a bit old-school at first glance but something like Clojure is basically designed to look aesthetically pleasing.
- spdegabrielle 5y agoI’d heard that homoiconicity isn’t real and there is no meaningful definition?
- reikonomusha 5y agoA language is homoiconic if code in that language is written using the syntax of data literals of that language. In the case of most Lisps, code is written using the syntax of list and symbol literals. (There are other literals too, of course.) (I (usually) like apples) is a nested list literal with four symbols. You can think of symbols as "interned strings"; they're written without quotes for convenience. It's not unlike ["I", ["usually"], "like", "apples"] in Python, except I had to use actual strings instead of symbols because Python doesn't ship with a standard symbol type. This is also a nested literal list: (loop for i below n do (print i)) but this happens to be a list literal that can be "run" (or in Lisp parlance, evaluated) as code.
- whycombs 5y agoI've been using hylang lately to build libraries for my python projects. It's a lot of fun, and close enough to Clojure that there's very little learning curve.
- vindarel 5y agoI encourage people to try out Common Lisp because, unlike with Hy, you will get: speed, ability to build binaries, truly interactive image-based development (yes, more interactive than ipython), more static type checks, more language features (no closures in Hy last time I checked), language stability… To reach to Python libs, you have https://github.com/bendudson/py4cl https://github.com/bendudson/py4cl My comparison of Python and CL: https://lisp-journey.gitlab.io/pythonvslisp/ https://lisp-journey.gitlab.io/pythonvslisp/
- peatmoss 5y agoHy is cool because it allows people to explore some lisp concepts in context of libraries they may already be familiar with. And Python has an enviable set of batteries. But compared to CL or Racket, Python’s performance is a bitter pill to swallow.
- Kodiologist 5y agoEven with PyPy, or Python libraries that are themselves written in C?
- mrtranscendence 5y agoPyPy won't be a candidate in some scenarios (nor is it always that much faster), and even libraries written in C leave some performance on the table when Python is the glue language. Don't get me wrong, I'm hardly ever in a position where Python limits me from a performance perspective ... there's always Cython. But it could be better.
- masklinn 5y agoThere's also a new kind on the block with mypyc, though it's pretty much pre-alpha and I assume it comes with a very long list of limitations.
- peatmoss 5y agoI ended up replying in a different thread on Python Performance: https://news.ycombinator.com/item?id=31272681#31275210 https://news.ycombinator.com/item?id=31272681#31275210
- jhbadger 5y agoHave they ever fixed the problem with let not being implemented (which was the case when I looked at it a couple of years ago). Lisp-like languages without let lose a lot of the inherent power of lisps.
- rcarmo 5y agoIt's sort of back, implemented as a macro. I've yet to go back to Hy (I left because of the removal of let, plus other things I found missing), but I try it every now and then and the last time I did the namespacing was still a tad weird.
- gilch 5y agoHave you tried Hissp yet?
- EnderShadow8 5y agoThis might be interesting https://pypi.org/project/scoping/ https://pypi.org/project/scoping/
- Kodiologist 5y agoIt's been implemented, found to be subtly broken, and re-implemented a number of times. Ultimately trying to impose a different model of scoping on top of Python's scoping is living in a state of sin; thus the difficulties. The status quo is an apparently working `let` due to a truly heroic effort by Sunjay Cauligi ( https://github.com/hylang/hy/pull/2125 https://github.com/hylang/hy/pull/2125 ). You're encouraged to try to find bugs in it. In truth, I've never understood the fuss about `let`. It's taken a huge amount of Hy development effort, but it adds very little. Python's native scoping works well in the large majority of cases, and in tricky cases, I'd rather use `nonlocal` or `global` explicitly so I'm sure what's happening at the level of Python semantics. I suspect that people who heard that previous versions of Hy were missing `let` assumed that some other feature (such as nested lexical scopes) was also missing that has actually always been there.
- contravariant 5y ago
- spapas82 5y agoDoes it support some kind of repl driven development similar to lisp/clojure? Ie evaluate expressions on a live app and update the live up with the new values?
- Kodiologist 5y agoI'm not familiar with such a feature, but you can certainly run a Hy program and edit its state in the REPL at the same time, if that suffices.
- potta_coffee 5y agoI haven't used Hy for anything serious but I've poked around with it before and it's loads of fun.
- billfruit 5y agoThe experience I had with it the last time i tried it was that it was syntactically very similar to Clojure, but certain subtle differences with it. Close but not being precisely same as something else could often result in confusions.
- Kodiologist 5y agoI'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.
- m45t3r 5y agoI completely understand the decision and applaud the fact that Hy seems to be going of a direction of being a much finer layer than it was previously (removing things from Hy itself and moving to Hyrule, for example). On the other side I am quite torn about the decision. I quite liked the early releases of Hy where I could write a code that was much more familiar for me as a Clojure programmer. Still need to give a try to the new releases though.
- simulate-me 5y agoThe first snippet of code I see on that page requires me to understand way too much syntax. It's nice to see smaller snippets of code when first exploring a new language to decide if it's worth the effort to learn the syntax and language features.
- gilch 5y agoWould you prefer something like this? https://hissp.readthedocs.io/en/v0.3.0/lissp_quickstart.html https://hissp.readthedocs.io/en/v0.3.0/lissp_quickstart.html
- simulate-me 5y agoNot really. I want to understand why the language is interesting. For instance, even though I know nothing about Lisp, I can guess that it supports booleans, integers, and floats. Tuples and complex numbers are kind of interesting. But then it goes on to strings and concatenation, which I already assumed were possible in Lisp.
- gilch 5y agoThe Hy page had way too much syntax, but the Hissp Quick Start didn't have enough? Or not soon enough? One does have to understand the little pieces to make sense of the big ones. You want something in between? Can you point to an example at the right level? Ctrl+F and try skipping to ";;;; The Basic Macros" section on that quick start page. Is that about the right level? For many of the "popular" languages, a simple cheat sheet showing the equivalent control structures in a common language might be enough for a typical programmer to get a handle on it quickly. But Lisp is not an Algol-family language. It's different enough that such a document would fail to convey what makes it interesting. There's an inferential gap that must be bridged first, and it's difficult to do that quickly; a programmer mistakenly [expecting a short inferential distance][1] may not have the patience to "get it". [1]: https://www.lesswrong.com/posts/HLqWn5LASfhhArZ7w/expecting-short-inferential-distances https://www.lesswrong.com/posts/HLqWn5LASfhhArZ7w/expecting-...
- adenozine 5y agoThere’s also https://github.com/basilisp-lang/basilisp https://github.com/basilisp-lang/basilisp If you desire a path closer to clojure
- chrisrink10 5y agoHey! I'm the author of Basilisp. Thanks for the mention here! Basilisp is much less mature than Hy but tries to stay generally compatible with Clojure, which is somewhat different than the goals of the Hy project.
- Kodiologist 5y agoCool, 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.
- chrisrink10 5y ago
- JasonFruit 5y agoHy is a false promise. It looks like a lisp; depending on your idea of a Platonic lisp, it may be a lisp --- but it preserves Python semantics, including its odd scoping rules, and it doesn't feel like writing actual lisp. Scheme or Common Lisp simply feel more coherent, having semantics that make sense with the language.
- Kodiologist 5y agoI'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.
- mumblemumble 5y agoAgreed. If odd scoping rules are the problem, we can possibly disqualify most lisps that have ever existed. Including all of the ones that John McCarthy had a hand in building. For my part, I had similar "this doesn't feel quite like lisp" moments with both Hy and Clojure. And I ultimately realized that it's the mere presence of the base platform that gets me. With Racket, I'm used to feeling like I'm sealed off in my own lispy bubble. With Hy and Clojure, there are always bits of Python or Java (read: Not Lisp) hiding in the background. Many differences from other well-known lisps that I know are attributable to that base platform. And that's a catch-22 situation. Objectively, they might be (and, IMO, are) good design decisions. But they're also covered in non-lisp cooties. I don't know why I should expect otherwise. Brains are weird.
- quasarj 5y agoWhat is odd about Python scoping rules?
- xigoi 5y agoVariables are function-scoped, not block-scoped. So you can do this: if 2 < 3: s = "Math works" else: s = "Math doesn't work" print(s)
- adg001 5y agoSo, Hy allows "to freely mix imperative, functional, and object-oriented styles of programming." I wonder: 1/ Shall we mix multiple paradigms of programming in the same project? 2/ Should we adopt a single programming language that supports multiple programming paradigms and utilise single paradigm for each given project, for the sake of minimizing the skill set required to the development team and – not necessarily –the learning curve?
- pmarreck 5y agoand any time a language allows this "free mixing", it loses the very tangible guarantees of purely-functional languages such as immutable data, emphasis on no side effects, etc.
- natrys 5y agoThis encouraged me to go back and get a two year old small project up to scratch with current Hy: https://github.com/natrys/ghdl https://github.com/natrys/ghdl I definitely had fun writing that in Emacs/hy-mode. And indeed having access to Python ecosystem is neat. However, if I may: - I didn't get to use any intellisense, which was quite painful. Is there any Language Server for Hy now? - I think Hy tends to break with every Python minor release, which is a bit annoying. Stable is still broken on 3.10, and alpha is a big change. - This one might be a matter of subjectivity but I felt that Hy is trying to be more "pythonic" and less "lispy", and I am not sure what to feel about that. For example, familiar things like `&kwargs` or `&optional` seems to have got replaced with something less familiar (particularly, change to `#**` for keyword arguments spurred this though).
- Kodiologist 5y ago1. 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 https://news.ycombinator.com/item?id=31250992
- gilch 5y agoNot Intellisense, but there is jedhy: https://github.com/ekaschalk/jedhy https://github.com/ekaschalk/jedhy which can do completions. Last Hy version verified working for: Hy 0.16.0
- gilch 5y agoHissp is an alternative approach. Unlike Hy, which compiles to Python AST, Hissp compiles to Python, so it doesn't break with every Python release. Its read language (Lissp) doesn't have an Emacs mode (yet), but its syntax is so close to traditional Lisps that lisp-mode pretty much works. No completions either. There is Lily https://github.com/mjobuda/damascus-tools/tree/main/lily https://github.com/mjobuda/damascus-tools/tree/main/lily, which proved Jedi works on Lissp, but it's never quite worked right. Hissp leans more Lispy than Pythonic compared to Hy, but still prioritizes interop, so the object model is still Python's.
- revskill 5y agoMost of python system i've seen is full of bugs, lack of stability, which causes huge damage from developer resources as well as operational costs. It's too hard for a junior Python developer to produce a reliable system. One of the reason as i know is, they have no idea of using unit test.
- eternityforest 5y agoLooks pretty neat, for the LISPy use cases out there. I think metaprogramming is a bit of an antipattern in most use cases(The more power the programmer has, the less the compiler/linter can follow it, just because... there's more possibilities). But for the stuff it that needs it, it seems to be unbeatable, and this seems to have type annotations, which fixes one of traditional lisp's ickiest things. Plus, having access to Python's libraries should make it possible to really evaluate what LISP can do by as a language, rather than having the choice mostly made by ecosystem size for a lot of projects. I prefer a much more predefined structure that fits in better with autocomplete, and focuses more on reuse than new ideas, but I could see some pretty amazing stuff being done in this, and it being a benefit to the Python community as well.
- gilch 5y agoStatic analysis becomes less important in a language with a REPL and dynamic reloading. Analyze the code by running it and inspecting the results.
- eternityforest 5y agoNot sure I follow the logic. That sounds like running non-repeatable unit tests by hand. You don't really have any help from the system, it's all on you to ve sure you've tested every code path, and it doesn't produce any formal report like a linter's "No warnings" message. Nor can other devs repeatably do the same tests and get a list of warnings to work on, you can't automatically test the whole existing codebase when new static checking comes by, etc. It's super useful for experimenting when you aren't sure of something, and it's great to have a debug console in the debugger, but I've never been that much of a fan of interactive programming in most cases. Plus, the same annotations used for static analysis also drive modern intellisense type tools, so even the most quick casual project can still have some pretty great documentation with almost no time cost.
- gilch 5y agoI'm not suggesting anyone stop writing tests. Rather I was referring to tools like Cider, which provide intellisense-like features by analyzing runtime state without static analysis: https://docs.cider.mx/cider/usage/misc_features.html#find-references https://docs.cider.mx/cider/usage/misc_features.html#find-re...
- casualrandomcom 5y agoI always thought the main reason lisp did not become the world's dominant language (or, at least, dominant language with garbage collection) is that writing (/ (+ (- b) (sqrt (- (* b b) (* 4 (* a c)))) (* 2 a)) is a pain in the neck, and even more so when you have to read it, while (-b + sqrt(b*b - 4*a*c))/(2*a), can be checked on the fly. I am kind of amazed this hasn't finally sunk into programmers' hearts.
- vindarel 5y agoPeople who write that much math can use a reader macro for infix notation: https://github.com/rigetti/cmu-infix https://github.com/rigetti/cmu-infix
- Kodiologist 5y agoIn Hy, you can include Python with `py`, as in (py "(-b + sqrt(b*b - 4*a*c))/(2*a)")
- m45t3r 5y ago> I always thought the main reason lisp did not become the world's dominant language (or, at least, dominant language with garbage collection) is that writing I can write ugly code in any language. But if I was writing this code in Clojure, I would probably do something like this: (let [r1 (- (* b b) (* 4 a c)) r2 (+ (- b) (sqrt r1))) r3 (* 2 a)] (/ r2 r3)) That is perfectly readable to me. Yeah, you may say that I needed to introduce other variables to make this work and the code got bigger as a result, but on the other side how many people are actually writing this kinda of code on daily basis that are not Computer Scientists?
- gilch 5y agoEven indenting properly goes a long way: (/ (+ (- b) (sqrt (- (* b b) (* 4 (* a c)))) (* 2 a)) The trick is that a trail of any number of `)`'s should also end the line. Like any language, it takes some getting used to, but I find this tree structure perfectly readable now. Sure for the four-function calculator operations, operator precedence levels are a reasonable notation, but when you can define your own functions, and your programming language now needs a dozen precedence levels, it becomes hard to read. Lisp is completely unambiguous.