Python to Javascript
Simon posted a comment on my post about the C# to Javascript compiler pointer out that there is a Python to Javascript system.
So far I've come across converters to Javascript from the following languages:
Even the JSScheme system might count, as the JIT essentially compiles Scheme into Javascript. I've been able to run this from Rhino to compile the Scheme code to Javascript and run it in the browser. All it would need is some nice libraries to wrap the DOM and use AJAX.
Categories: javascript, python
So far I've come across converters to Javascript from the following languages:
Even the JSScheme system might count, as the JIT essentially compiles Scheme into Javascript. I've been able to run this from Rhino to compile the Scheme code to Javascript and run it in the browser. All it would need is some nice libraries to wrap the DOM and use AJAX.
Categories: javascript, python

5 Comments:
If JSScheme counts then Prolog in Javascript counts as well.
while interesting at a brain-teaser level, these conversions seem to have no practical application. almost everything one might code in javascript is focused on DOM manipulation, forms processing, etc in a web page environment. how much python or C# has been written for these tasks? none i presume, since there is no practical support for using these languages in this capacity in the first place (which requires more than just DOM apis). actually microsoft may support C# as they support VB in the browser, i don't use microsoft products so i don't know.
i know this is terrible circular logic and it does not preclude the "interestingness" of these converters, i guess i am just venting because i would love to see true multi-language support in the browser runtime, but treating javascript as a compiler target just doesn't rub me as the right direction to go (although it is the only direction you can go today). users will suffer bloated and buggy event layers, and ultimately we won't be able to exploit the utility of our languages of choice, they will just be chrome for javascript.
anyway, i really do appreciate your continued focus on the area of multilanguage activity, these posts are very informative and in your own way you are shining a light on a problem space i think is very important.
another one is oberon script.
ralph sommerer mentions the eventual possibility of "porting" the oberon system (of which I used to be a great fan) to the browser - that's of course a while away, but with widespread cross-browser canvas support (see ralph's work or explorercanvas) &c. it's becoming more feasible by the day. whether it makes sense is a wholly different question, but why spoil the fun?
will we one day look back onto js1 as the x86 of the new millenium?
Also I may not provide a details, but my ex-coworkers had done last year a project, that automatically translates Tcl/Tk application to server-side environment (J2EE at server, JavaScript + IE HTC + Mozilla bindings in browser).
So up to certain extent even Tcl translation is possible ;)
Now that v8 from google is out, these -to-javascript compilers definitely have practical application. and as pyv8 demonstrates, they have practical application in being an accelerator for the original languages.
in the case of pyv8, a ten-fold empirical observed increase in the execution speed, compared to the standard python interpreter, was observed.
http://advogato.org/article/985.html
so, although pyjamas ' heritage is from a browser-based realm, pyjs.py actually has absolutely nothing to do whatsoever with browsers. the only classes that have anything to do with browsers, in pyjamas, is its DOM.py module. to illustrate that clearly, i ported pyjamas to the desktop: pyjamas-desktop which is the same widget-set in pure python (using http://webkit.org for the DOM model manipulation). but that's getting off-topic.
so yes - whilst initially the most obvious environment to run javascript is in a browser, pyv8 demonstrates that it's not _just_ there where it's of benefit. making javascript an intermediate language (instead of the forth-like bytecode that python uses, for example) allows you to leverage the speed of the assembly-level JIT compilers such as google's v8, to get massive performance gains.
Post a Comment
<< Home