Hacker News new | ask | show | jobs
by ddragon 2099 days ago
I can't say anything about smalltalk since I only played with the VM once and don't know the whole story, but I can think of two reasons why Lisp even though they are more dynamic than Python (for some definition of dynamic) it's easier to JIT.

First is compile-time (macro) and runtime separation, which allows an escape path to move the dynamism out of runtime, so the most powerful transformations doesn't even concern the JIT optimizations (outside of running the macros exactly as described). That's in contrast to R, which is inspired by Lisp like Julia but uses optional lazy evaluation to implement a lot of what a macro can, but it's harder to optimize since the JIT can't just separate and then optimize. And in Python, metaprogramming also requires exploiting heavily runtime tricks (sometimes even considering implementation details of CPython) that then must be properly supported and efficiently executed by any JIT.

Second is cultural, processing power was not abundant when most Lisp dialects were created and became popular, so the ecosystem grows more aware of what dynamism is good and what is bad. Julia is another example, Julia developers since it's release are much more performance aware, so they don't deliberately abuse "Any" containers or type unstable code, eval, runtime function redefinitions and invokelatest, global variables, some types of introspection and other anti-patterns that any JIT built after the fact (decades of libraries later) would have incredible trouble making fast. And in Python, the performance aware people always focused on the FFI instead of restriction the harder to optimize parts of the language, which only made it harder for a Python-only performance solution that can handle this polyglot ecosystem.