Hacker News new | ask | show | jobs
by hencq 4711 days ago
While it's certainly an interesting project, I wonder how practical it is. All javascript engines have powerful JITs and it seems like a waste not to use them, but instead to implement your own interpreter. I think the approach taken by e.g. clojurescript or dart is more viable, where they compile to javascript and let the JIT do its magic.
2 comments

As mentioned in the link, the goal is to eventually use the JIT - the title does contain "First Steps" in it ;)

No reason this approach cannot JIT into JS just like clojurescript and dart.

If I read it correctly, his goal is to use the PyPy JIT. So what he's doing is translating the PyPy JIT (which is created automatically from the interpreter written in RPython) into javascript. Because he's using emscripten this javascript code can be statically compiled by virtue of asm.js (in Firefox at least).
Yes, he plans to use the PyPy JIT, but it will generate code that is then JITed by the JS engine JIT.

It doesn't require special static compilation to optimize small amounts of JITed code, all modern JS engines can do that extremely well. asm.js is not necessary there.

The big problem with that approach and Python is Python's dynamic object model. It's really hard to completely emulate that completely in javascript, and by then it would probably not be that much cleaner, smaller or faster than CPython compiled to Javascript.

Without the type system however, Python in the browser is next to useless in practice.