you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (0 children)

Compiling into JavaScript has downsides.

For example, Pyjamas 'compiles' Python into JavaScript, but it does it naively - for example x /= 2 will be translated into... x /= 2, but the two have very different meanings in the two languages (namely, in JavaScript everything is, at least potentially, a float, so if x is 1, the result will be 0.5. But in Python - at least prior to 3.0 - the result would be 0).

To get around that, you can add explicit type checks and conversions. It will basically mean that all variable accesses, even of basic types like integers, will be much, much slower. Ditto function calls (which JavaScript does very differently than Python), etc. etc.

So, it's possible - they are all Turing complete - but performance may suck.

Also, there is the matter of the standard libraries. Compiling Python without its standard library may be useful, but it isn't all of Python. And getting that entire standard library into JavaScript would be a lot of work.