6 ms·
A week with Hy
- tosh 7y agothe original was published on https://0bin.net/paste/xmJWIlIv+Ws+Fbjs#zCyc4Yc4T+YISv3MHwMTwScu0as4xzqjns9YKaw1v1k https://0bin.net/paste/xmJWIlIv+Ws+Fbjs#zCyc4Yc4T+YISv3MHwMT...
- dotdi 7y agoI saw Hy pop up a week or so ago and I've decided to give it a serious spin since I've always wanted to learn a Lisp but never wanted to learn a whole new eco-system. It's been phenomenal so far and I want to finish my comment the same way the author finishes his blog post: > It stands on the shoulders of a giant (Python) and balances another giant (Lisp) on top of this. Better is better, guys. pip install hy.
- maest 7y agoIs there a guide/overview/doc/tutorial/whatever of how Hy is implemented? I'm curious how hy modules can be imported in python directly.
- dfox 7y agoPython has API that allows you to replace parts of import system with arbitrary Python code.
- maest 7y agoIf you are talking about the import hooks, I think those require the imported file to have valid python syntax. The import hooks work on the python AST (I think)
- greenshackle2 7y agoI think you are correct, they monkey-patched importlib https://github.com/hylang/hy/blob/master/hy/importer.py#L132 https://github.com/hylang/hy/blob/master/hy/importer.py#L132
- btwillard 7y agoAs I recall, patching was simply the most expedient approach. Otherwise, for the changes we needed to make, we would've had to copy a lot of source from the standard loader implementation in CPython for only a few simple changes. https://github.com/hylang/hy/pull/1672 https://github.com/hylang/hy/pull/1672
- marmaduke 7y agoI went down this path until I tried to run pdb or profilers on mixed language stuff, result was not great. Python is already fairly OK, use decorators instead of def macro, metaclasses if you need to get into head-scratching territory etc. Use the 4 argument form of the type function, belabor __new__ etc it will still be readable instead of a pile of nail clippings
- foobar_ 7y agoCan you distribute packages with hy?
- jdc 7y agoYep. Check out the GitHub list: https://github.com/hylang/hy/network/dependents?dependent_type=PACKAGE https://github.com/hylang/hy/network/dependents?dependent_ty...
- baruchel 7y agoDon't take it bad, but here is my attempt in creating a new "Lisp dialect" compiling into BASIC: (main (linenumber 10 (print "hello world")) (linenumber 20 (print "Hey!")) (goto 10)) More seriously, is Hy anything more than writing Python with some parentheses there and there? Coding in Lisp has nothing to do with putting parentheses everywhere but rather with thinking in some specific way. For instance, I know that I am ready to code something in Lisp when I see my whole task as a sequence of CONS, but how could Hy truly implement such a thing as long as it relies on Python lists?
- ken 7y agoOr in actual Lisp: (tagbody 10 (print "hello world") 20 (print "Hey!") (go 10))
- klipt 7y agoIn many cases Python generators are better than lists: https://wiki.python.org/moin/Generators https://wiki.python.org/moin/Generators E.g. consider xrange() vs (Python 2) range().
- foobar_ 7y agoNeeds relative line numbering from vim.
- yeezyseezy 7y agoThe only real advantage I saw in the article is the addition of macros
- testaccount10 7y agoYour example looks great! Now i want (defmacro print-loop (line-start line-inc strings) (let ((i line-start)) `(main ,(mapcar (lambda (x) `(linenumber ,(setq line-start (+ line-start line-inc)) (print ,x))) strings) (goto line-start))))
- greenshackle2 7y agoI played with it a bit, it's homoiconic, has macros, and papers over the difference between Python statements and expressions (so that everything is expressions). Seems pretty neat, if you ask me.
- Animats 7y agoThis is a humor article, right? (Hell is debugging someone else's LISP macros. I have a very old LISP program, a theorem prover, I've tried to convert from Franz LISP, a Maclisp dialect, to Common LISP. I worked on it years ago. I just can't fix some of the bugs. The original authors of the part that doesn't work right are long dead.)
- serpix 7y agoHy is what got me into lisp dialects and parted the clouds on the bliss of simplicity of the syntax and made me see that I had been living like a savage with C-style languages and OO slavery. Give it a try! It is really fun and significantly lowers the barrier off entry to the land of lisp!
- wodenokoto 7y agodef prepare_target(y): if hasattr(y, "values") return target.values.reshape(-1,1) else: return target.reshape(-1,1) Shouldn't that be def prepare_target(y): if hasattr(y, "values") return y.values.reshape(-1,1) else: return y.reshape(-1,1)
- chmielewski 7y agoThank you paultag