1. 20

  2. 7

    I first heard about Hy for livecoding blender which I thought was pretty interesting.

    1. 4

      This is an interesting approach — it (essentially) lets you write the Python AST in lisp form, so you can do macros and metaprogramming with the ease of Lisp. But you’re still really just writing Python.

      1. 2

        dumb question - would it be possible to make a Common Lisp that targets Python ala how ABCL targets the JVM?

        1. 3

          AFAIK, Python doesn’t have a representation lower than Python syntax trees (which is what Hy targets). In other words there’s no more-general “Python VM” to target. In a literal sense you could certainly implement a Common Lisp in Python (or any other language), but I don’t know if it would be useful other than an academic exercise.

          1. 3

            Yeah I guess maybe it would be something that could target just CPython bytecode or whatever PyPy uses, but not work with both

            1. 2

              I investigated further…in standard Python you can disassemble a function’s bytecode, but not create a function from bytecode. Python bytecode is explicitly an implementation detail not portable across Python versions (much less implementations). However, people have made libraries to play with CPython bytecode.

              All that said, Python bytecode seems very Python-specific, and implementing a significantly different language on it would probably be quite painful (as with the early JVMs).

          2. 2

            Not a dumb question—of course you can, but you’re not going to get performance any better than Python as you’ll have to a) compile to Python, b) simulate some features of Common Lisp that aren’t native to Python. Multi methods are a great example of something that wouldn’t be as fast as “native” Python.