Python needs to be natively supported as a scripting lang in browsers. Google, MS, Firefox - make it so!
As much as I like Python, I don't think this is the right approach. What browsers need to do is to have a machine-level bytecode, so that they can download whatever interpreters are needed to run the scripting code the page uses. Then pages can be written in whatever language the developer feels is best. This is the real potential of something like Native Client - although it doesn't look like that potential will be…
Brython - Python to Javascript translator
31–40 of 71 posts
Re: Brython - Python to Javascript translator
#32Wow! This is so awesome. This has been tried before, but I don't remember why it never succeeded. I wonder if this can get the appropriate community to make it a decent alternative compared with TypeScript and CoffeeScript - or maybe I'm missing something here?
Re: Brython - Python to Javascript translator
#33I think compiler is the wrong way to describe this. A computer program that translates between two different high level languages is typically called a language translator .
Wouldn't "preprocessor" be a more accurate description?
Re: Brython - Python to Javascript translator
#34Repl.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…
Much of the slowness was because emscripten was immature at the time that repl.it worked on their port. If someone built python with current-day emscripten it should be much faster.
There is a better way, though. We could compile PyPy's generated C implementation and add a JIT to JS to that. That would be the best way to get fast python into the browser. If anyone is interested to hack on that let me know, I would assist from the emscripten side.
Note though that this would only give throughput speed, not startup speed. For startup speed, a method like pyjamas or bython will do better - at the cost of not fully supporting the python language, of course.
Re: Brython - Python to Javascript translator
#35Earlier quoted context omitted.
As much as I like Python, I don't think this is the right approach. What browsers need to do is to have a machine-level bytecode, so that they can download whatever interpreters are needed to run the scripting code the page uses. Then pages can be written in whatever language the developer feels is best. This is the real potential of something like Native Client - although it doesn't look like that potential will be…
As much as I don't like Microsoft, I actually think the .NET CLR would be an excellent choice for such a runtime. NaCl not so much; target architecture-dependent compiled code is a major downside.
Re: Brython - Python to Javascript translator
#36Earlier quoted context omitted.
As much as I like Python, I don't think this is the right approach. What browsers need to do is to have a machine-level bytecode, so that they can download whatever interpreters are needed to run the scripting code the page uses. Then pages can be written in whatever language the developer feels is best. This is the real potential of something like Native Client - although it doesn't look like that potential will be…
As much as I don't like Microsoft, I actually think the .NET CLR would be an excellent choice for such a runtime. NaCl not so much; target architecture-dependent compiled code is a major downside.
http://www.chromium.org/nativeclient/pnacl/building-and-test...
Re: Brython - Python to Javascript translator
#37Wow! This is so awesome. This has been tried before, but I don't remember why it never succeeded. I wonder if this can get the appropriate community to make it a decent alternative compared with TypeScript and CoffeeScript - or maybe I'm missing something here?
In the end, it was hard to replicate 100% of the usefulness of JS through python and convert python's cool features into JS.
Re: Brython - Python to Javascript translator
#38Wow! This is so awesome. This has been tried before, but I don't remember why it never succeeded. I wonder if this can get the appropriate community to make it a decent alternative compared with TypeScript and CoffeeScript - or maybe I'm missing something here?
Because as cool as the project is (from a scientific perspective), ultimately it will end up not being used by anyone. Most developers and companies who build production grade software for a living stick to true and tried technologies, vs. fancy esoteric stuff like this.
Don't get me wrong, I am not knocking this project and the person who created it, I am just stating the obvious reason why things like this rarely take off.
Re: Brython - Python to Javascript translator
#39https://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 ghastly Python.
The difficulty is providing all the class semantics and the standard library.
Re: Brython - Python to Javascript translator
#40Very nice. Can this approach be generalized to embed Clojure, Haskell, and other languages into the browser? I love the pervasiveness of JavaScript but I dislike writing it. This is a very good tradeoff.
https://github.com/clojure/clojurescript
http://www.haskell.org/haskellwiki/The_JavaScript_Problem
https://github.com/jashkenas/coffee-script/wiki/List-of-lang...