On 26 Sep 2005 at 8:56, holger krekel wrote: > > I believe the idea with a PyPy/JS Interpreter is more > interesting, at least from the PyPy perspective. Btw, > being faster than current JS interpreters is probably > easier than being faster than CPython :-) > Such a JS-interpreter implementation could be > integrated with browsers allowing JS and Python > directly in the browser. > > That being said, it might actually be worthwhile to compile > RPython to Javascript which should be reasonably fast > for small programs. One possibility is to just create > flowgraphs from a python program and then transform the > flowgraph to javascript source code (without much > annotation). > > I guess only real experiments would shed more light. > Hello everyone. Python and prototypes is one area where I have some personal experience.
How well RPython will translate to Javascript depends on how fully RPython supports new-style classes. Javascript objects have single inheritance only. So problems arise immediately for multiple inheritance. An object space is needed to implement new-style classes on top of Javascript prototypes. All python arithmetic operations, attribute accesses and method calls become Javascript function calls. This adds a level of indirection to an already slow interpreter. Finally Javascript has no 'goto' statement. So a switch statement within a loop is needed to handle the spaghetti code produced by tranforming a flowgraph. How much different is this from an interpreter loop? So a Python program compiled to Javascript is essentially a Python interpreter that runs in Javascript. How worthwhile is this? Of course if RPython only supports single inheritance and improvements to flowgraph transformation will recover Python's statement structure then a closer translation may be possible. Lenard Lindstrom <[EMAIL PROTECTED]> _______________________________________________ pypy-dev@codespeak.net http://codespeak.net/mailman/listinfo/pypy-dev