Live data from Hacker News

Brython - Python to Javascript translator

brython.info

41–50 of 71 posts

Re: Brython - Python to Javascript translator

#41
post #19

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…

There's no such thing as a language-agnostic bytecode. A bytecode is just a compressed source encoding of some language.

Re: Brython - Python to Javascript translator

#42
post #31

Earlier 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…

Pages downloading and executing things just reminds me of ActiveX from the late 90s. I think South Korea still relies on the technology for their home-grown version of SSL.

Pages download and execute things all the time. The problems with ActiveX was that it was tied to the Windows API, and that it wasn't sandbox - it wasn't the idea of downloading code.

Re: Brython - Python to Javascript translator

#43
post #19

Python needs to be natively supported as a scripting lang in browsers. Google, MS, Firefox - make it so!

Python is a really big and complicated language to include in Browsers. And think of the version hell: If you think Pyhthon 3 compatibility is apain, imagine if we still had to use Python 2.2 on Firefox or something like that.

Re: Brython - Python to Javascript translator

#44
As a lover of Python myself, this is awesome.

However, as others are noting things that are missing that we pythonistas can't live without (generators, classes, etc)- I feel it is worth a reminder that Javascript 6 (Harmony) is going to have a lot of these built in.

Brendan's slides have a great overview of what's to come (and makes me hope writing JS outside of CoffeeScript will become more bearable since I'm so spoiled by Python:

http://brendaneich.github.com/Strange-Loop-2012/

Re: Brython - Python to Javascript translator

#45

Wow! 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?

There is no shortage of compile-to-JS languages. For a non-comprehensive list, see

https://github.com/jashkenas/coffee-script/wiki/List-of-lang...

For many of the offerings in the list, the problem, IMHO, is the lack of a complete story.

If you base it on an existing language - in this case, Python - you would expect a full implementation of the language, or at least a good portion of the core language features. The benefits of an existing language are often familiarity and the potential to reuse existing code. With partial implementation, you can hardly gain these. And the downside of extra abstraction quickly outweighs any superficial perception of familiarity.

If you create a new language, you have to strike a good balance between language features and interoperability. You need to bring enough new things to the table to make it worthwhile to learn, adopt and support it, and yet you can't overstate the importance of a good interoperability story unless you can afford to completely ignore the JavaScript ecosystem. See DART.

Re: Brython - Python to Javascript translator

#46
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.

Re: Brython - Python to Javascript translator

#48

Wow! 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?

Once brython gets some key missing Python features (classes, list comprehensions, lambdas), and some libraries for it, I think it has huge potential.

Indeed! Right now Coffee script offers more expressive power than this. So they should add these features fast if they want this to succeed in the highly competitive world of compile-to-js languages!

Re: Brython - Python to Javascript translator

#49
post #19

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…

I don't think that it's the right approach only ever to allow JavaScript (just because every time anything else is mentioned, we inevitably go off on this tangent).

There is no indication that browsers are going to standardize on a VM (let alone NaCl) any time soon.

If someone just stopped bikeshedding and did Python in the browser, there's no reason a machine-level bytecode or whatever couldn't be implemented later.

Re: Brython - Python to Javascript translator

#50
post #43
post #19

Python needs to be natively supported as a scripting lang in browsers. Google, MS, Firefox - make it so!

Python is a really big and complicated language to include in Browsers. And think of the version hell: If you think Pyhthon 3 compatibility is apain, imagine if we still had to use Python 2.2 on Firefox or something like that.

These arguments are terribly heuristic. The full stack of software included in any significant JavaScript app is big and complicated. There are already runtime differences, and we aren't saying that those make JS unusable. There is not going to be a big 3->4 migration any time remotely soon. No 'version hell'. The current story for Python compatibility is certainly much worse!
Post reply on HN