Python on JavaScript VM's (such as V8)?

B

Berco Beute

I wonder what it would take to implement Python in JavaScript so it
can run on those fancy new JavaScript VM's such as Chrome's V8 or
Firefox' tracemonkey. Much the same as Python implementations in C#
(IronPython) and Java (Jython). It would certainly bring back the fun
in web application development. Is there anything done in that
direction?

2B
 
B

bearophileHUGS

Berco Beute:
I wonder what it would take to implement Python in JavaScript so it
can run on those fancy new JavaScript VM's such as Chrome's V8 or
Firefox' tracemonkey. Much the same as Python implementations in C#
(IronPython) and Java (Jython). It would certainly bring back the fun
in web application development. Is there anything done in that
direction?

The mythical beast pypy is supposed able to translate Python to
Javascript too, I think. From some of my benchmarks Chrome's V8 is a
little slower than Psyco... so the matter is how much efficiently can
be Python translated in JS.

Bye,
bearophile
 
L

lkcl

Berco Beute:

it's been done. http://pyjamas.sf.net


that's been done, too.

http://advogato.org/article/985.html

it's great :) been using it just for fun, for about 18 months.
http://lkcl.net/site_code
and for a personal project
http://partyliveonline.com
and for a commercial project which i'm sorry i can't refer you to the
development site right now.

Is there anything done in that direction?

yup. quite a lot.
see http://groups.google.com/groups/pyjamas-dev
The mythical beast pypy is supposed able to translate Python to
Javascript too, I think. From some of my benchmarks Chrome's V8 is a
little slower than Psyco... so the matter is how much efficiently can
be Python translated in JS.

well, the llpamies pyjamas branch from sep 2007 has some definite
improvements in the _features_ provided (python-wise) but some time
after that, one too many interoperability features were added (proper
support for **kwargs) and it just... blew up, got too complicated for
luiz and he abandoned the effort.

i've outlined on pyjamas-dev what work needs to be done to satisfy
both goals of remaining efficient and also providing support for
**kwargs.

one _much_ more important requirement - over-and-above
"efficiency" (which isn't that bad anyway in pyjs.py) is readability.

remember you have to _debug_ these xxxxing programs .... in
javascript, not python (which is why i did pyjamas-desktop - http://pyjd.sf.net
so you could keep on using the standard python interpreter and _then_
run the same app through pyjs.py to convert it to javascript).

l.
 
L

lkcl

That's hardly an implementation of Python inJavascript-

someone _is_ considering validating the pyjs.py interpreter to ensure
that it's NP complete. however, it's an academic exercise that's not
driven by an actual real-world need.

basically, running pyjs.py and the standard python 2.5 "compile"
module under pyv8. just for kicks :)

so, the beginnings of the process - to bootstrap your way entirely
into javascript-land, where you'd be able to "input" python and have
it compiled _to_ javascript _by_ a python-to-javascript compiler which
_itself_ has been compiled to javascript - the foundations have been
laid.

and it's not _as_ crazy as it sounds. sufficient tests to demonstrate
unequivocably that the equivalent javascript _is_ equivalent; you then
have pyv8 empirically demonstrating a ten times - TEN times for
goodness sake - performance increase - that's got to be worth it.

especially if it can be done "automagically", behind the scenes, so
that when you type "python myapp.py" instead of executing forth-like
byte code (myapp.pyc) you "execute" javascript (myapp.pyj).

it's a
partial Python toJavascripttranslator.

compiler. python to javascript _compiler_ :)

with a more complete python-to-javascript compiler in http://code.google.com/p/pyjamas
subversion - you'll need the llpamies branch, but you'll _also_ need
to go back to around sep 2007. somewhere in between then and now,
luis tried to add proper support for **kwargs and he didn't complete
it.

Still looks good though.

yeh :)
 

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,992
Messages
2,570,220
Members
46,807
Latest member
ryef

Latest Threads

Top