Python to JavaScript Compiler? Anyone written such a beast?

K

kenneth.m.mcdonald

Of course, I'm not talking about something that would transform
any Python code into semantically JavaScript code, but simply
something that would analyze a "restricted" Python source file,
and spit out equivalent JavaScript. The big advantage (as far
as I'm concerned) is that one could make use of some of the
syntactic shortcuts that JavaScript doesn't offer, that the Python
syntax checker generally does a better job than the JS one, and
(perhaps most importantly) this could be configured to put in 'instrumentation',
such as checks to make sure than an attempt to access an undefined
attribute actually throws an error.

Color me curious,
Ken
 
S

Steve Holden

Of course, I'm not talking about something that would transform
any Python code into semantically JavaScript code, but simply
something that would analyze a "restricted" Python source file,
and spit out equivalent JavaScript. The big advantage (as far
as I'm concerned) is that one could make use of some of the
syntactic shortcuts that JavaScript doesn't offer, that the Python
syntax checker generally does a better job than the JS one, and
(perhaps most importantly) this could be configured to put in 'instrumentation',
such as checks to make sure than an attempt to access an undefined
attribute actually throws an error.

Color me curious,
Ken
Take a look at the PyPy project, which has produced a JavaScript
back-end (thugh I suspect it's more of a curiosity than a practical
solution). It might suit your needs, though, and they've had a Summer of
Code project going on it.

http://codespeak.net/pypy/dist/pypy/doc/news.html

and specifically

http://codespeak.net/pypy/dist/pypy/doc/getting-started.html

regards
Steve
 
B

Ben Finney

Of course, I'm not talking about something that would transform any
Python code into semantically JavaScript code, but simply something
that would analyze a "restricted" Python source file, and spit out
equivalent JavaScript.

You may be looking for Pyjamas:

<URL:http://pyjamas.pyworks.org/>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top