Saturday, April 30, 2005

Technical - "Jython Essentials"

Jython is the programming language Python, but implemented in pure Java and meant to run on Java JVMs. "Jython Essentials" is an O'Reilly book on Jython. Python is a scripting language that's been around for a while. Python came into being little later than Perl, but from a programming language design point of view is a much cleaner language.

The cool thing about Jython is its seamless integration with Java. Unlike other languages that can be compiled to run on the JVM, Jython supports full access to all Java libraries. In fact you can write Jython classes that extend Java classes.

You can also imbed Jython into Java programs to give your program scripting control.

I'm working on a small Jython project at work, so I have been refering to this book a bit lately. I haven't actually read the book from cover to cover, but I just read selected chapters (like the chapter on Swing or reflection). Some of the Jython examples in the book are pretty neat - there is a page long Web browser (!).

One thing I'm learning while doing the little project, is to use some of the functional language features of Jython. Some of these are just basic things from Lisp (like applying a function to each element of a list), but others are more sophisticated. For instance I finally figured out what "closures" are and I was actually using this construct in my code.

If you want to learn Python/Jython this probably not the book to use. But if you want to quick overview of Jython features or you need a quick reference, this is the right book.

2 Comments:

At 8:21 AM, Blogger Fuzzy Thoughts said...

Python in Java?? What's next, Jisp? How about Jodula? ;-)

Seriously, what's the advantage of coding in Python over using Java directly?

 
At 8:25 AM, Blogger richieb said...

Actually is pretty useful to have your application execute scripts (without the need for compilation or without even stopping) , if you embed the interpreter in the app.

I know people who imbedded Python into big FORTRAN programs to be able to easily "steer" them.

Other than than, Python/Jython is a nice scripting language, with many OO and functional language features. It's advantage over straight Java is less code and no compilation.

 

Post a Comment

<< Home