471,071 Members | 1,480 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,071 software developers and data experts.

Python instead of Javascript?

Wouldn't it be nice if we could program our browser in Python instead of
Javascript?

- Eric

Oct 23 '05 #1
7 3485
Eric van Riet Paap wrote:
Wouldn't it be nice if we could program our browser in Python instead of
Javascript?


Wouldn't it be nice if people would not troll?
PointedEars
Oct 23 '05 #2
Eric van Riet Paap wrote:
Wouldn't it be nice if we could program our browser in Python instead of
Javascript?


I don't really like Python, but it, Mozilla family browsers and Konqueror[1]
are open source, IE has an API such that you can add support for other
scripting languages (PerlScript being the only example that springs to
mind).

http://aspn.activestate.com/ASPN/doc...ml#client_side

So feel free to write and contribute patches (and an IE plugin). A
JavaScript newsgroup probably isn't the best place to discuss such things
though.
[1] and code in Konqueror often drifts into Safari

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Oct 23 '05 #3
On Sun, 23 Oct 2005 21:46:38 +0100, David Dorward <do*****@yahoo.com>
wrote:
Eric van Riet Paap wrote:
Wouldn't it be nice if we could program our browser in Python instead of
Javascript?


I don't really like Python, but it, Mozilla family browsers and Konqueror[1]
are open source, IE has an API such that you can add support for other
scripting languages (PerlScript being the only example that springs to
mind).


PythonScript already exists, aswell as alternative versons of
ecmascript, there's lots of options.

The OP is free to use python today with IE.

Jim.
Oct 23 '05 #4

Why would it be nicer? I mean, we can make the same claim for C++ or VBS
or Perl, or even Bash, if you mean more access to more objects, that's
implementable in the API, some are not due to security, no inability, same
applies with any API really.
Danny
Oct 23 '05 #5
Eric van Riet Paap wrote:
Wouldn't it be nice if we could program our browser in Python instead of
Javascript?

I'm as rampant a Python enthusiast as they come, but the answer to your
question is 'no'.

You can enable scripting with Python in *your* copy of Internet Explorer,
but Javascript was designed as a web scripting language whereas Python is a
general purpose programming language. Strange as that may seem, and even
though the design of Javascript is a mess in several places, it means that
Javascript is the better choice.

The main problem using Python as a browser scripting language is that it is
virtually impossible to sandbox a script. In effect, if you permit web
pages to invoke Python scripts you are exposing your system to attack.
Sure, if you re-implement Python from the ground up you could produce a
version which respected the appropriate levels of security, and in fact it
has been done at least twice (Jython, IronPython) but you have to do it by
implementing Python from scratch on a secure platform, not by bolting on
security.

Rather than considering Javascript vs Python, a better comparison is Java
vs Python, and here at least the choice is simple: use Jython and gain from
quicker and easier development or stick with Java for smaller downloads and
faster runtime speed. Downloading the runtime to the client is more likely
to be the decider: any noticeable performance differences can probably be
eliminated by recoding a few sensitive areas in Java.

Of course, if what you actually meant was Python running as a trusted
application driving the browser then with IE that is trivial through COM,
and Mozilla will be sprouting XUL support for Python (and possibly other
languages) in the near future (according to
http://weblogs.mozillazine.org/roadm...es/008865.html, 1st November
is the date to watch).
Oct 24 '05 #6
I have started a (restricted) Python to Javascript translator as part of
PyPy. PyPy is a Python interpreter written in Python.
More info on PyPy can be found at
http://codespeak.net/pypy/dist/pypy/doc/news.html

The Py->JS translator will take some time before it becomes fully usable,
but it can translate some smal Python script to Javascript already.

- Eric

Duncan Booth wrote:
Eric van Riet Paap wrote:
Wouldn't it be nice if we could program our browser in Python instead of
Javascript?

I'm as rampant a Python enthusiast as they come, but the answer to your
question is 'no'.

You can enable scripting with Python in *your* copy of Internet Explorer,
but Javascript was designed as a web scripting language whereas Python is
a general purpose programming language. Strange as that may seem, and even
though the design of Javascript is a mess in several places, it means that
Javascript is the better choice.

The main problem using Python as a browser scripting language is that it
is virtually impossible to sandbox a script. In effect, if you permit web
pages to invoke Python scripts you are exposing your system to attack.
Sure, if you re-implement Python from the ground up you could produce a
version which respected the appropriate levels of security, and in fact it
has been done at least twice (Jython, IronPython) but you have to do it by
implementing Python from scratch on a secure platform, not by bolting on
security.

Rather than considering Javascript vs Python, a better comparison is Java
vs Python, and here at least the choice is simple: use Jython and gain
from quicker and easier development or stick with Java for smaller
downloads and faster runtime speed. Downloading the runtime to the client
is more likely to be the decider: any noticeable performance differences
can probably be eliminated by recoding a few sensitive areas in Java.

Of course, if what you actually meant was Python running as a trusted
application driving the browser then with IE that is trivial through COM,
and Mozilla will be sprouting XUL support for Python (and possibly other
languages) in the near future (according to
http://weblogs.mozillazine.org/roadm...es/008865.html, 1st November
is the date to watch).


Oct 24 '05 #7
Eric van Riet Paap wrote:
The Py->JS translator will take some time before it becomes fully usable,
but it can translate some smal Python script to Javascript already.


I must admit to being sceptical that you can translate Python to Javascript
without some fairly major semantic changes. Surely just implementing a
Javascript equivalent of a Python dictionary is virtually impossible?
Oct 24 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Jakub Fast | last post: by
5 posts views Thread by Sells, Fred | last post: by
22 posts views Thread by lechequier | last post: by
8 posts views Thread by jkn | last post: by
4 posts views Thread by Berco Beute | last post: by
4 posts views Thread by Joe Hrbek | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.