3 ms·
If you want to do this kind of thing on the server side, Python provides enough introspection to turn functions in a live Python image into JavaScript. Here's a
by madhadron 14y ago
If you want to do this kind of thing on the server side, Python provides enough introspection to turn functions in a live Python image into JavaScript. Here's a minimal example I tossed together a while back:
https://gist.github.com/50d706081074aed8fcf6 https://gist.github.com/50d706081074aed8fcf6
I have a bunch of notes somewhere on translating a big hunk of the basic language, including how to generate continuation passing style code in JavaScript from less ghastly Python.
The difficulty is providing all the class semantics and the standard library.
- ville 14y agoI like the simplicity of that gist. Very cool hack. However if I was to implement a Python to JavaScript compiler, would there be some benefits in transforming the Python AST into a JS AST first? There are existing code generators such as escodegen that transform that AST to JavaScript code.