I first heard about Hy for livecoding blender which I thought was pretty interesting.
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.
dumb question - would it be possible to make a Common Lisp that targets Python ala how ABCL targets the JVM?
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.
Yeah I guess maybe it would be something that could target just CPython bytecode or whatever PyPy uses, but not work with both
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).
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.