Can it run real programs (i.e. not benchmarks)?<p>If so I will be impressed. Glancing over the code, it looks pretty short, and I can imagine benchmarks will run, but not real programs.<p><a href="https://github.com/PythonJS/PythonJS/blob/master/pythonjs/pythonjs.py" rel="nofollow">https://github.com/PythonJS/PythonJS/blob/master/pythonjs/py...</a><p>It's true that most programs don't use all the dynamism of Python, but they probably depend on something that does (e.g. Django). Python is more dynamic than JavaScript, in that it has __getattr__, __setattr__, __getitem__, etc.<p>If not, it's not fair to compare it to PyPy... PyPy actually runs arbitrary Python programs.
I also wrote an interpreter, and it's 500x faster than CPython or PyPy.<p>(As it happens, my interpreter can only run a single fixed program, but I'm not worried: most people won't read past the headline when I announce it.)
The other interesting and recent "Python in the browser" project is RapydScript - <a href="https://github.com/atsepkov/RapydScript" rel="nofollow">https://github.com/atsepkov/RapydScript</a><p>Unlike PythonJS, it does not have the goal of being 100% Python compatible, but instead takes the CoffeeScript approach. So, like Coffeescript, you get (mostly) clean Javascript output, no huge library dependency, runs nearly as fast as Javascript, etc.<p>Check out the "ants" demo - <a href="http://salvatore.pythonanywhere.com/RapydBox/default/editor" rel="nofollow">http://salvatore.pythonanywhere.com/RapydBox/default/editor</a><p>I've been playing around with both PythonJS and Rapydscript, and I like both. Different goals. PythonJS can output to Lua, too - so there's the whole Python in LuaJIT angle which could be very interesting as it matures.
According to the footnote he tested with pypy 1.9. There was just a post here a day or two ago that pypy 2.3.1 was release. Seems like one should at least use the latest version when testing. Pypy 1.9 was release 2 years ago.
This just translates Python syntax into JavaScript, assuming a direct translation is possible.<p>Neat, but a more compelling post would compare with CoffeeScript and check build times, high-level syntax, and features like generators, list comprehensions, itertools, functools, and so on.<p>Edit: why the downvote? Am I incorrect about something? If so, I'm genuinely curious to know what I'm overlooking here.<p>Edit 2: I went over to the github page and it is in fact a 'transpiler', though it can run self-hosted in node, and the features list includes both list comprehensions and
yield (i.e. generator functions). It looks like the itertools and functools libraries aren't supported yet, but doing so really wouldn't be too difficult. CoffeeScript is a direct output option too.
Python has bignums by default. I was curious how PythonJS implemented bignums, so I tried it, and the answer is: it doesn't. It just uses ordinary JavaScript doubles.<p>This is a critical difference that ought to be called out, especially in the "add" micro-benchmark, which is measuring two very different things in the two implementations.
If this project gains more traction, maybe it will get more people interested in Dart. (which is essentially javascript with a standard library reimagined for the things people are using javascript for today: async APIs, stream processing, mapreduce, webapps, etc.)
Near as I can tell, because CPythong is so tied to native code at every turn, none of the other VMs have any real chance of success without bridging to them.
Ah yes, the old X is faster than Y pointless nonsense. Let's ask the basic questions that always come to mind:<p>- Does X do all or at least most that Y does?<p>- Are the benchmarks sane? I.e. not the pointless arithmetic fibonacci that nobody really uses, but the useful stuff such as regexps etc.
PyPy uses JIT to generate optimized code during runtime. As many comments noted, PythonJS may not support all Python features but still don't understand why PyPy performing worse than PythonJS.
The comparisons to PyPy would be much more meaningful if they weren't based on a version of PyPy that's <i>over two years old</i>: PyPy 1.9 was released in 2012.
Nitpick: vertical text is really hard to read, sp if the image is compressed like that. Next time please use some bars instead of columns!<p>Asides from that, this looks quite promising!