Once upon a time I wrote Oink, which generates JS from Python on the server: https://github.com/alecthomas/oink It has support for many of the Python niceties: classes, list comprehensions, positional arguments, and so on. Interesting experiment, but I ended up thinking that Python is not the best language for the browser.
Brython - Python to Javascript translator
51–60 of 71 posts
Re: Brython - Python to Javascript translator
#52Looks really cool. And i love Python. However, I think the Python Syntax will make it hard to minify the code, which is probably not that important anyway when not in production. But for production usage it would be cool to have a real compiler instead of an interpreter. But yeah. Cool stuff.
Re: Brython - Python to Javascript translator
#53http://code.google.com/p/brython/source/browse/trunk/py_clas...
this is both incorrect (exceptions are propagated, http://paste.pound-python.org/show/28457/) and has wrong complexity. It's not even a dict at all!
Re: Brython - Python to Javascript translator
#54I'm genuinely shocked that this made it to the top of hackernews. I would expect better. While the idea of having the Python interpreter in the browser is very likely better than having a compiler Python -> JS (if we care about Python), the implementation here is both half assed and really bad. It takes quite a bit of effort to create a python interpreter that can be called python. This is nowhere near there. On top…
Re: Brython - Python to Javascript translator
#55Repl.it has supported python on the browser for a while: http://repl.it/ (an an interpreter, not as a translator, though). It also supports ruby, scheme, lua and others[1] What made it impractical was the slowness. Emscripten seems to work fine for clang[2], not so much for interpreted languages. Maybe the translator path can solve this issue. [1] http://repl.it/#:languages [2] https://developer.mozilla.org/en-US/dem…
Although, speed is way less important when the code is running on lots of browsers out there, compared with running lots of instances on your server.
Re: Brython - Python to Javascript translator
#56I'm genuinely shocked that this made it to the top of hackernews. I would expect better. While the idea of having the Python interpreter in the browser is very likely better than having a compiler Python -> JS (if we care about Python), the implementation here is both half assed and really bad. It takes quite a bit of effort to create a python interpreter that can be called python. This is nowhere near there. On top…
If someone makes a good looking website for his project it kind of gives the impression that he is seriously going for it, perhaps it is not good now, but maybe it will become a serious contender later.
Re: Brython - Python to Javascript translator
#57I'm genuinely shocked that this made it to the top of hackernews. I would expect better. While the idea of having the Python interpreter in the browser is very likely better than having a compiler Python -> JS (if we care about Python), the implementation here is both half assed and really bad. It takes quite a bit of effort to create a python interpreter that can be called python. This is nowhere near there. On top…
There are many OPs that assert that JS syntax/lang are beautiful once you get handle of it, and may be it is...
However, there may be enough people like myself for whom the JS syntax/lang just do not fit into the brain. Since at my last job of CFO of $200+m pharma country org I have architected multidimensional db for an OLAP cube for SAP Business Objects, I do not think that I am that dumb. But this JS stuff just does not fit in.
Also, I do value my time. So although I could persist in learning JS, as a general rule when things do not flow - the learning time multiplies. I do not have time.
Hence, personally I would love to be able to write/maintain code in Python [even subset of Python would be fine], knowing that it cleanly compiles to JS. It will be then my choice whether I want it client-side or server-side [smth like what css pre-processors SASS/Less are doing].
Re: Brython - Python to Javascript translator
#58Also worthy of mention in this context: http://pyjaco.org/about and http://pyjs.org/
Based on your personal experience - with which one to start?
Re: Brython - Python to Javascript translator
#59If you want to do this kind of thing on the server side, Python provides enough introspection to turn functions in a live Python image into JavaScript. Here's a minimal example I tossed together a while back: https://gist.github.com/50d706081074aed8fcf6 I have a bunch of notes somewhere on translating a big hunk of the basic language, including how to generate continuation passing style code in JavaScript from less g…
However if I was to implement a Python to JavaScript compiler, would there be some benefits in transforming the Python AST into a JS AST first?
There are existing code generators such as escodegen that transform that AST to JavaScript code.