use for jython?

Alex Martelli aleax at aleax.it
Sun Mar 30 04:22:09 EST 2003


Erik Max Francis wrote:

> David McNab wrote:
> 
>> Jython seems good for browser applets.
>> Wonderful to be able to write those suckers in Python without having
>> to touch a single line of J---
> 
> Well, I can sympathize with your reaction (it's darn neat), but it
> doesn't seem fair to call
> 
> from java.applet import Applet
> 
> class HelloWorld(Applet):
>   def paint(self, g):
>     g.drawString("Hello from Jython!" 20, 30)
> 
> "not touching a single line of Java," given that this wouldn't make a
> lot of sense without already knowing at least some elements of the Java
> standard library.

Some Java advocates steadfastly refuse to distinguish between the
LANGUAGE Java, the LIBRARIES that Java can use, and deployment
aspects such as Java _virtual machines_.  Personally, I've always
found this confusion deplorable.  I prefer to use Java, in the
right context, to mean *the Java LANGUAGE* -- just as I use other
language names.  Admittedly the use of X to mean "the X language"
AND the rather different concept of "the X language PLUS its
standard library" is ambiguous.  When one needs to pedantically
distinguish, one CAN rephrase the sentence you object to "not
coding a single line in the Java language".  But that should be
the normal interpretation in this context -- calls to some Java
_libraries_ are clearly needed (though they might well be hidden,
e.g. if anygui ever grows an AWT front-end;-) -- so it's not all
that "unfair".


> It's Python, but it's really Python-as-Java rather than something
> entirely independent of Java.

It's "independent of Java" much like classic Python is "independent
of C", i.e., no real connection to the _language_ (Java or C) used
under the covers to implement Python, but plenty of connections to
the _libraries_ accompanying said implementation language (classic
Python gradually moves away from such library dependencies, e.g. by
now using a Python implementation of strptime rather than relying
on that in the underlying C libraries if any, but it's a long and
slow process and Jython is still young;-).

Today there is no practical way to use Jython productively without
SOME background knowledge of Java-oriented libraries relevant to
your project, and the docs and examples for such libraries are no
doubt going to be "talking Java" so you need a nodding acquaintance
with how to *read* Java snippets.

But being able to read and understand a programming language is
still quite a way from CODING stuff in that language.  And, at least
in theory (were the market to expand enough to warrant writing such
specialized books), there would be no problem writing a book that
teaches some relevant subset of Java's standard library in Jython
terms, requiring no knowledge of the Java *language*.

Today, I still recommend to would-be users of Jython to get some
fundamental Java reference (e.g. "Java in a Nutshell") next to a
Python one (e.g. "Python in a Nutshell", but of course I'm biased)
AND a Jython-specific book too (e.g "Jython Essentials") -- PLUS
whatever tutorial or reference materials (books or otherwise) one
needs for specific libraries one needs to use.  But then, I've
always been a keen fan of RTFM'ing; I know some other people who
prefer to "dive in, feet first", and that approach suits them --
it's applicable to Jython at least as well as to other cases, a
bit more I'd say because Jython's interactive mode can let you
explore in a reasonably effective way.


Alex





More information about the Python-list mailing list