Live data from Hacker News

Why we need Python in the Browser

archlinux.me

11–20 of 132 posts

Re: Why we need Python in the Browser

#11
post #7

For some time now I've been wondering why the primary scripting format consumed by browsers is JavaScript (a language intended for humans) and not some sort of standard bytecode that would be executed in a browser's virtual machine. What we need is the JSVM! In other words, something like the JVM but adapted for the browser. That probably means it would have a more dynamic typing focus since it makes sense for JavaSc…

I'm sure we could have some sort of JSVM, we could even have some sort of bytecode for the HTML, but it would destroy part of what makes the web so great: it's openness. The ability to view the source of any webpage, and even make chances and enhance it locally.

There is also the fact that certain optimization can only be done by the browser if it has the actual source code rather than the compiled bytecode.

Re: Why we need Python in the Browser

#12
post #7

For some time now I've been wondering why the primary scripting format consumed by browsers is JavaScript (a language intended for humans) and not some sort of standard bytecode that would be executed in a browser's virtual machine. What we need is the JSVM! In other words, something like the JVM but adapted for the browser. That probably means it would have a more dynamic typing focus since it makes sense for JavaSc…

Lots of essential Python features are not part of the language, but belong to its standard library. The thing that makes JavaScript so portable is that it basically has no such thing (except maybe Date and Math).

So to make convenient use of Python in the browser (or even to be able to run currently existing Python code), you wouldn't just have to embed the interpreter – you would have to ship this huge library. And you would have to do that for each language you want to support.

Re: Why we need Python in the Browser

#13
post #2

An ideal situation would be installable interpreters that still allowed you to use a system-wide rendering engine. I actually think Windows had something similar with ActiveScripting. I assume something like QT allows you to script the webview with whatever language you have bindings for? Unfortunately QT+bindings is a pretty long way from 'zero install'

Sounds more like plugin hell to me. I think it's becoming increasingly harder to convince users to install browser plugins (for good reasons), and it's not even possible on most mobile browsers.

As with the original article I'm talking about desktop apps which would already require an installer. It's just about reducing the pain of that install.

Re: Why we need Python in the Browser

#14
post #7

For some time now I've been wondering why the primary scripting format consumed by browsers is JavaScript (a language intended for humans) and not some sort of standard bytecode that would be executed in a browser's virtual machine. What we need is the JSVM! In other words, something like the JVM but adapted for the browser. That probably means it would have a more dynamic typing focus since it makes sense for JavaSc…

We do have that VM. It just happens that this VM's "bytecode" looks like JavaScript.

Here is Python running in the browser:

http://syntensity.com/static/python.html

Re: Why we need Python in the Browser

#15
post #6

Can the rpython translator support js as a target? Could you compile pypy to js that way, to provide a python environment in existing browsers? To be honest though, JS is a perfectly OK language for web browsers, and if you really want to reuse python code it probably makes more sense to translate it before it gets to the browser, using automated tools or otherwise. Supporting everybody's favourite language natively…

That's not what the article is proposing.

Re: Why we need Python in the Browser

#16
post #14
post #7

For some time now I've been wondering why the primary scripting format consumed by browsers is JavaScript (a language intended for humans) and not some sort of standard bytecode that would be executed in a browser's virtual machine. What we need is the JSVM! In other words, something like the JVM but adapted for the browser. That probably means it would have a more dynamic typing focus since it makes sense for JavaSc…

We do have that VM. It just happens that this VM's "bytecode" looks like JavaScript. Here is Python running in the browser: http://syntensity.com/static/python.html

Yes. And it just happens that it's optimized for js and sucks compared to a lower level VM.

Not to mention the extra overhead, not having proper traces for exceptions, source-line equivalency on errors, etc.

Re: Why we need Python in the Browser

#17
post #5

Many people would be very surprised to see what MS Pyton is capable of (-:

Sure, Silverlight can run Python, but Microsoft has stepped away from plugins in IE10, and SL/ML run poorly or not at all in most other desktops and tablets.

Re: Why we need Python in the Browser

#18
post #14
post #7

For some time now I've been wondering why the primary scripting format consumed by browsers is JavaScript (a language intended for humans) and not some sort of standard bytecode that would be executed in a browser's virtual machine. What we need is the JSVM! In other words, something like the JVM but adapted for the browser. That probably means it would have a more dynamic typing focus since it makes sense for JavaSc…

We do have that VM. It just happens that this VM's "bytecode" looks like JavaScript. Here is Python running in the browser: http://syntensity.com/static/python.html

Sorry, but this is not good enough. This argument is made all the time, but all you're really saying is that every other language should be a second-class citizen to JavaScript. Emscripten is a cool technical hack, but why the fuck is it 2012 and we have to compile C++ to JavaScript?

Re: Why we need Python in the Browser

#19
It seems that the primary method of disagreement used by only-JavaScript-in-the-browser advocates is as follows:

1. Talk about the "open web"; 2. Tell you to compile to JavaScript.

I really don't understand why this is considered a reasonable response to people who just want to build things with the language they prefer, without being treated as second-class citizens.

Re: Why we need Python in the Browser

#20
As a user of Real Programming Languages (Common Lisp, Java, C) I'm indifferent to scripting languges, but if I had to choose ONE to see in the browser, it would be Lua.

It has sane, symmetric minimal design that gets closures. It also looks like a programming language. I can type Lua into the Firebug repl and not worry about indentation.

Post reply on HN