Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Can Python work like Java Applet?

1 view
Skip to first unread message

Haoyu Zhang

unread,
Oct 22, 2003, 10:41:32 AM10/22/03
to
Dear Friends,
I am in the process to choose which to learn. Java or Python? I was told that
Python is much more neat. But I am not sure about its functionality. Can it
support something like Java Applet? If so, I will learn this one.

Thanks a lot for your help.

Best,
Haoyu

Batista, Facundo

unread,
Oct 22, 2003, 10:58:27 AM10/22/03
to Python-List (E-mail)
#- I am in the process to choose which to learn. Java or
#- Python? I was told that
#- Python is much more neat. But I am not sure about its
#- functionality. Can it
#- support something like Java Applet? If so, I will learn this one.

AFIK, no. But, remember that 'Java' and 'Java Applet' are different things.
And 'Java' doesn't support something like 'Java Applet'.

Just don't get confused by the names. Browsers have embedded a 'Java Applet'
interpreter. You can't execute Java there.

. Facundo

Jim Dabell

unread,
Oct 22, 2003, 11:16:45 AM10/22/03
to
Batista, Facundo wrote:

> #- I am in the process to choose which to learn. Java or
> #- Python? I was told that
> #- Python is much more neat. But I am not sure about its
> #- functionality. Can it
> #- support something like Java Applet? If so, I will learn this one.
>
> AFIK, no. But, remember that 'Java' and 'Java Applet' are different
> things. And 'Java' doesn't support something like 'Java Applet'.

Excuse me? A Java applet is built with Java. Perhaps you are thinking of
Javascript?


> Just don't get confused by the names. Browsers have embedded a 'Java
> Applet' interpreter. You can't execute Java there.

Of course you can, that's the whole point!

Anyway, to answer the original question, browsers don't have a built-in
Python runtime, but that doesn't really matter as you can use JPython to
construct a Java applet from Python sources.

Take a look here for more information:

<URL:http://www.jython.org/applets/>

Remember that this has the same drawbacks as with Java applets - not all
user-agents (browsers) support them, and it's often a better idea to do
things on the server.


--
Jim Dabell

Werner Schiendl

unread,
Oct 22, 2003, 11:36:02 AM10/22/03
to
Batista, Facundo wrote:

> AFIK, no. But, remember that 'Java' and 'Java Applet' are different things.
> And 'Java' doesn't support something like 'Java Applet'.
>
> Just don't get confused by the names. Browsers have embedded a 'Java Applet'
> interpreter. You can't execute Java there.
>

I think that here is some confusion.

A "Java Applet" as to my best knowledge *is* Jave, but it runs in a very
limited sandbox that prevents it from doing bad things to the machine
where the browser runs.

If you *really* need that sort of thing (that is, run custom code in a
clients browser) Java will be your best bet as it is the only approach
that is somewhat cross-platform.

Another possibility to run code in a browser would be ActiveX (which is
only available on Windows) or writing Browser-PlugIns (which are
platform and browser dependent).


My recommendation to the original poster would be to learn both :-)

best regards

Werner

Alan Kennedy

unread,
Oct 22, 2003, 11:51:18 AM10/22/03
to
[Batista, Facundo]

>> Just don't get confused by the names. Browsers have embedded a 'Java
>> Applet' interpreter. You can't execute Java there.

[Jim Dabell]


> Of course you can, that's the whole point!
>
> Anyway, to answer the original question, browsers don't have a built-in
> Python runtime,

Actually, that's not strictly true. The win32all windows extensions
install a python interpreter COM object, which can used as a scripting
plugin with the Windows Scripting Host (WSH), meaning that one can
embed python in an HTML page, in the same manner as Javascript.

Documentation is here:

http://www.python.org/windows/win32com/ActiveXScripting.html

However, your script will only run on Internet Explorer browsers that
have python *registered* as a scripting language. Which is possibly
not a problem on an Intranet, where one can make's one's users install
the plugin, but is unlikely to have widespread support on the
Internet.

The "install" vs. "register" distinction is necessary because
registering python as a scripting language opens up some serious
security holes. Because python doesn't currently have a restricted
execution ("sandbox") environment similar to java applet-playing
plugins, python scripts embedded in pages displayed by Internet
Explorer have pretty much total control over the users machine. The
first report of that, with details of some potential attacks, can be
found here:-

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&selm=3C44A774.5DFCDE15%40computerbytesman.com

> you can use JPython to
> construct a Java applet from Python sources.

An excellent solution.

I would recommend to the OP to consider learning *both* java and
python at the same time, by learning jython. Others may strongly
disagree however.

regards,

--
alan kennedy
-----------------------------------------------------
check http headers here: http://xhaus.com/headers
email alan: http://xhaus.com/mailto/alan

Batista, Facundo

unread,
Oct 22, 2003, 12:34:14 PM10/22/03
to Python-List (E-mail)

#- > AFIK, no. But, remember that 'Java' and 'Java Applet' are different
#- > things. And 'Java' doesn't support something like 'Java Applet'.
#-
#- Excuse me?  A Java applet is built with Java.  Perhaps you
#- are thinking of
#- Javascript?

You're fully right.

MY mistake, sorry.

.       Facundo





. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

ADVERTENCIA 

La información contenida en este mensaje y cualquier archivo anexo al mismo, son para uso exclusivo del destinatario y pueden contener información confidencial o propietaria, cuya divulgación es sancionada por la ley.

Si Ud. No es uno de los destinatarios consignados o la persona responsable de hacer llegar este mensaje a los destinatarios consignados, no está autorizado a divulgar, copiar, distribuir o retener información (o parte de ella) contenida en este mensaje. Por favor notifíquenos respondiendo al remitente, borre el mensaje original y borre las copias (impresas o grabadas en cualquier medio magnético) que pueda haber realizado del mismo.

Todas las opiniones contenidas en este mail son propias del autor del mensaje y no necesariamente coinciden con las de Telefónica Comunicaciones Personales S.A. o alguna empresa asociada.

Los mensajes electrónicos pueden ser alterados, motivo por el cual Telefónica Comunicaciones Personales S.A. no aceptará ninguna obligación cualquiera sea el resultante de este mensaje.

Muchas Gracias.

John J. Lee

unread,
Oct 22, 2003, 1:50:28 PM10/22/03
to
Alan Kennedy <ala...@hotmail.com> writes:
[...]

> [Jim Dabell]
> > Of course you can, that's the whole point!
> >
> > Anyway, to answer the original question, browsers don't have a built-in
> > Python runtime,
>
> Actually, that's not strictly true. The win32all windows extensions
> install a python interpreter COM object, which can used as a scripting
> plugin with the Windows Scripting Host (WSH), meaning that one can
> embed python in an HTML page, in the same manner as Javascript.
>
> Documentation is here:
>
> http://www.python.org/windows/win32com/ActiveXScripting.html
>
> However, your script will only run on Internet Explorer browsers that

I think Mozilla supports this too (PyXPCOM).


> have python *registered* as a scripting language. Which is possibly
> not a problem on an Intranet, where one can make's one's users install
> the plugin, but is unlikely to have widespread support on the
> Internet.

[...]

I suppose you could write an ActiveX control to distribute CPython.
Writing a Java applet with Jython is the sane way to do it, of course
(security and amount of data to be transferred to the client).


John

John J. Lee

unread,
Oct 22, 2003, 1:56:27 PM10/22/03
to
Werner Schiendl <n17999950....@neverbox.com> writes:

> Batista, Facundo wrote:
[...]


> If you *really* need that sort of thing (that is, run custom code in a
> clients browser) Java will be your best bet as it is the only approach
> that is somewhat cross-platform.

[...]

And, just to hammer the point home for the OP, Jython will let you
write Java applets.

Jython is a implementation of Python -- Python and Jython are the same
language -- but, at the same time, Jython code compiles to Java class
files (which, of course, depend on a runtime library, itself written
in Java), and so Jython *is* Java in an important sense.

It's been said many times that it's easier to program Java in Python
(Jython in particular) than it is in Java.


John

Josef Meile

unread,
Oct 22, 2003, 2:56:20 PM10/22/03
to
> Anyway, to answer the original question, browsers don't have a built-in
> Python runtime, but that doesn't really matter as you can use JPython to
> construct a Java applet from Python sources.
>
> Take a look here for more information:
>
> <URL:http://www.jython.org/applets/>
Wow, it's amazing. I didn't tried jython before because I didn't need to use
java
classes from python, with the later have been always enough. However, I
always
like the idea of this python implementation. After seeing this, I think it's
worth to be
tested.

Thanks for the link,
Josef


Haoyu Zhang

unread,
Oct 22, 2003, 4:15:42 PM10/22/03
to
"Batista, Facundo" <FBat...@uniFON.com.ar> wrote in message news:<mailman.13.1066834...@python.org>...

Dear Facundo,
I think you mean Java Script here, right? I feel Java Applet is an
important application of Java. Thanks for your reply.

Haoyu

Cameron Laird

unread,
Oct 22, 2003, 4:38:04 PM10/22/03
to
In article <3f96a3b7$1...@brateggebdc5.br-automation.co.at>,

Werner Schiendl <n17999950....@neverbox.com> wrote:
>Batista, Facundo wrote:
>
>> AFIK, no. But, remember that 'Java' and 'Java Applet' are different things.
>> And 'Java' doesn't support something like 'Java Applet'.
>>
>> Just don't get confused by the names. Browsers have embedded a 'Java Applet'
>> interpreter. You can't execute Java there.
>>
>
>I think that here is some confusion.
>
>A "Java Applet" as to my best knowledge *is* Jave, but it runs in a very
>limited sandbox that prevents it from doing bad things to the machine
>where the browser runs.
>
>If you *really* need that sort of thing (that is, run custom code in a
>clients browser) Java will be your best bet as it is the only approach
>that is somewhat cross-platform.
.
.
.
Let's reconsider whether Java is "the only approach that is
somewhat cross-platform." Some of my Web-app-specializing
acquaintances tell me Flash, for example, is effectively both
more capable and portable than Java.

There have been at least rudimentary marriages of Flash and
Python. I suspect the two could get along quite well. I
don't know whether someone has already done this.
--

Cameron Laird <cla...@phaseit.net>
Business: http://www.Phaseit.net

Peter Hansen

unread,
Oct 22, 2003, 4:42:33 PM10/22/03
to
Cameron Laird wrote:
>
> Let's reconsider whether Java is "the only approach that is
> somewhat cross-platform." Some of my Web-app-specializing
> acquaintances tell me Flash, for example, is effectively both
> more capable and portable than Java.
>
> There have been at least rudimentary marriages of Flash and
> Python. I suspect the two could get along quite well. I
> don't know whether someone has already done this.

One rudimentary marriage -- some might call it a weekend fling --
exists in Twisted, where the (experimental?) LivePage feature
supports having ActionScript code in a zero-width Flash movie
sending client-side events through a socket opened to the
server, to allow dynamic interfacing of server-side Python code
and client-side events. Updates in the other directly are
supported as well, so that the server can cause arbitrary
Javascript code to be executed in the client...

It's pretty, uh, "twisted". (Even more so is that the IE version
of this seems to require some VBScript glue in the web page, to
interface Flash to Javascript. Let's see, that's four languages
interfaced together just to handle your onClick events. :-)

-Peter

MetalOne

unread,
Oct 22, 2003, 7:27:44 PM10/22/03
to
I actually tried this the other day.
I believe that it would be significantly easier to write Java Applets
in Jython than in Java. However, the size of my applet when compiled
with Jython was about 250k to do almost nothing. The same applet
written in Java with significantly more functionality was 12k.

Haoyu Zhang

unread,
Oct 22, 2003, 9:40:35 PM10/22/03
to
Dear Friends,

Thanks a lot for your replies. I get somewhat clarified. Anyway, I will
begin learning Python and Jython. And I will also learn Java when needed.

All the best,
Haoyu

0 new messages