May 02, 2002
Jython Essentials

I picked up Jython Essentials on my way home last night, more or less on a whim. I don't actually use Jython, but a juxtaposition of my language of choice, my favourite technical publisher, and my workaday language was impossible to resist.

Its a good book, and I learned a lot about Jython. It's even cooler than I thought. You can subclass Java classes in Jython, or vise versa. A Java class subclassed in Jython can then be re-subclassed in Java again. It's just all too cool to be true!

Type conversions between the two languages is pretty much automatic, though you can get fine control if you want it. You can embed Jython in a Java app if it needs scripting. You can compile a Jython app into a single Java class or jar, either a small one requiring the jython.jar to run, or a big standalone one. And the interactive prompt is a brilliant way to explore the behavior of Java existing classes, and to smoke test your own. It's a one stop shop for all your Java scripting needs.

It also got me thinking again about why I prefer Python to Java so much. The things which irritate me the most are these:

  • Boiler plate code. This is the code which you end up writing again and again and again. Looping through the containers, for example, requires so much code. Now I don't object to verboseness as such - where it adds value. But where it just adds characters, it's irritating. Python's


    for line in list:

    line.whatever()


    syntax is perfectly comprehensible, and concise.


    And don't get me started on Enumerations...


  • Integration of data structures into the language. You can't override the the built in operators for classes, which leads to very verbose code.


  • Hand holding. If Java tells me one more time that a local variable 'may not have been initialised', when I know damn well it will have been, I swear I'll scream.

Having said all that, Java has its pluses - interfaces are really cool, and JavaDoc is a wonderful tool.

Posted to Python by Simon Brunning at May 02, 2002 03:59 PM
Comments
Post a comment
Name:


Email Address:


URL:



Comments:


Remember info?