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).