473,497 Members | 2,041 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3718
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2381
by: Jakub Fast | last post by:
Hi, Does anybody know how far you can get nowadays with trying to use Python as the script language for XUL instead of JS? Is it possible (even theoretically) to write full-fledged applications...
5
2283
by: Sells, Fred | last post by:
I see there are several different choices for Python GUI API's. Is there any indication of which ones are 1. the most commonly used? 2. the most reliable? 3. the most robust?
22
1721
by: lechequier | last post by:
Let's say I define a list of pairs as follows: >>l = Can anyone explain why this does not work? >>h = {}.update(l) and instead I have to go: >>h = {} >>h.update(l) to initialize a...
8
2109
by: jkn | last post by:
Hi all I'm trying out, and in general finding really useful, the various TiddlyWiki variants that I guess many people here know about, for organising my activities in a GTD way. One mild annoyance...
2
10892
by: neeebs | last post by:
Hi, I'm not sure if this is a javascript problem per se, but here goes. I have an xsl document with a python function defined within a <script> block. Elsewhere in the xsl file, within a python...
4
2446
by: Berco Beute | last post by:
I wonder what it would take to implement Python in JavaScript so it can run on those fancy new JavaScript VM's such as Chrome's V8 or Firefox' tracemonkey. Much the same as Python implementations...
4
3102
by: Joe Hrbek | last post by:
Could someone help me translate to something that would close to it in python? The anonymous functions are giving me problems. var dataListener = { data : "", onStartRequest: function(request,...
0
6993
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7162
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6881
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7375
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4584
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1411
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
650
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
287
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.