Hacker News new | past | comments | ask | show | jobs | submit login
PyPyJS – PyPyBox (diodev.fr)
59 points by ArtyProg on March 20, 2016 | hide | past | favorite | 17 comments



For anyone actually looking to transpile Python into Javascript for web usage, please take a look at Transcrypt[1]. It's the only Py->JS Compiler that creates reasonable output sizes, readable code, and doesn't require loading a virtual machine.

1: http://transcrypt.org/

Edit: Shouldn't have said virtual machine, I meant a large runtime, though obviously a few implementations do have a proper VM.


And how exactly would Transcript be able to do entirely client-side what's on this demo, i.e. enter some Python code into a textarea, click "run" and have it executed? The answer is that it would not. However, you can do this with PyPyJS, Brython and a few others.


I did mention it in the context of "For anyone actually looking to transpile Python into Javascript for web usage", not for live execution. There are tons of options for web REPL.


Skulpt does require a VM, but e.g. Brython, RapydScript, PyJs and a few others do not.

Transcrypt seems to maintain a closer correspondence between source python and javascript, making debugging perhaps a little easier. But it doesn't look like it brings anything significantly new to the table.


The big thing it brings to the table is file size. The overhead is a few kilobytes, whereas the Brython runtime (the other smallest one I know of) is 110KB.


Transcrypt is next in a line of "let's convert syntax of Python to syntax of JS". Now this is really not what I want. I can learn and use new syntax without problems. What I want is to remove the annoyance of "undefined is not a function", automatic conversion int -> str, or even worse obj -> str, passing too little/too few args etc. etc. This is something that REQUIRES understanding of types and some VM to keep the semantics.


the only Py->JS Compiler that creates [...] readable code

Sorry, it may be readable, but it's not good JavaScript code. It would be much better for it to output optimised JS the way Babel/Coffee do.


I never claimed it outputted good Javascript, just that it was readable. I personally wouldn't use Transcrypt for anything, I'd just write Javascript.


There's also rapydscript-ng by the author of Calibre

https://github.com/kovidgoyal/rapydscript-ng/


Rapydscript is neat, but it's not exactly python. If I wanted to import a python package from PyPi into Rapydscript, I'd be SOL.


But you can't do that with Transcrypt, either. Both are "not quite python" and won't run regular python code. There is very little difference between the goal of the two projects.


Yes, you can. As long as the import is pure python code, it'll handle the import just fine.

Edit: Within reason. Anything involving the sys module is out, since there's no system to back it.


"Known restrictions...No standard libs...Not all methods of builtin types are there by default...No iterator, generator, xrange stuff."

There's also the fact that everything is still, at the core, pure javascript. For example you can't print("string" * 10) or even iterate over a dictionary.

I'm not saying this to put down the project - I am very interested in it - but it cannot parse pure python, and that isn't the goal of the project.


Granted, there are restrictions. However, a lot of those restrictions have disappeared in recent releases, and more are disappearing all the time. Iterators, generators, xrange, I expect those all to be included in due time. Additionally, re: the standard library, there is a project called Ouroboros[1] that replicates the standard library in pure python, and there was discussion regarding integrating that into Transcrypt.

You're right, it's not there yet, and I'm interested in it for purely theoretical reasons (I personally don't think I'd ever use Transcrypt for anything in production), but I think it holds great potential.

[1]: https://github.com/pybee/ouroboros/tree/master/ouroboros


I think PyPyJS could be a great tool for generative art.


I'd be interested in hearing you elaborate on that


Glad seeing there is somebody interested. I havent not actually choose which graphics library to use for backend. Feel free to email me

Regards

http://salvatore.diodev.fr/pypybox/




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: