Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!


Forgot your password?
Programming Books Media Book Reviews IT Technology

Python Programming with the Java Class Libraries 64

David Kennedy contributes the review below of Richard Hightower's new book Python Programming with the Java Class Libraries, subtitled A Tutorial for Building Web and Enterprise Applications with Jython, writing "This book tries to be suitable for both new and experienced programmers, and suffers from this decision. However, it presents all the central programming concepts clearly and is a decent primer on Jython. It is illustrated with copious code, and covers plenty of advanced topics. Worth reading if you're interesting in the Jython language. Oh, and ignore the sub-title."
Python Programming with the Java Class Libraries
author Richard Hightower
pages 448
publisher Addison-Wesley
rating B+
reviewer David Kennedy
ISBN 0201616165
summary Solid technical primer on Jython. Probably best for those with some comp. sci. experience.

First Impressions

We all know not to judge a book by its cover, but let's be honest; when looking at a bookshelf groaning with Learn ${technology} in 21 Days! and ${technology} for Utter Fools, it can be useful to have a filter to apply.

I have the following book-cover rules:

  • Ignore everything with a cluttered cover. If I find the cover confusing, I doubt the content will be better.
  • Look for an O'Reilly "animal" cover.
  • Look for an "Addison-Wesley Professional Computing Series" cover. These tend to be white, with a blue stripe down the side, usually accented with magenta. C++ programmers especially should have several titles from this excellent series on their shelves.

Given my third rule, I am dismayed to see that Addison-Wesley have chosen to go with a cartoonish cover featuring a luminescent python constricting a brown sack marked "Java Beans." It's not the worst cover art I've ever seen, but I have to admit that I probably wouldn't have noticed it on the shelf. I know this seems like a minor criticism, but it is a crowded market.

Target audience

So, who is this book targeted at? The blurb and publicity material make it clear that the volume has a split personality, seeking to satisfy both new programmers and experienced programmers.

I find this an odd decision, and while I can understand how it can be tempting to address both audiences at once, the end result feels more than a little fragmented. Let's have a look at the two cases.

If I was a new programmer, or was merely new to Python, would I choose this book over something more obviously targeted to me like the O'Reilly title, Learning Python (Mark Lutz and David Ascher)? I think I'd go with the O'Reilly title here if I was a novice, I mean, doesn't "building Web and Enterprise Applications" sound a little ambitious? Would a new programmer even understand the sub-title? (I've been working for over four years and I'm still not sure what exactly Enterprise is supposed to mean!)

Similarly, if I was an experienced programmer, perhaps in Java, would I pick up this book to get a handle on Python? Well, I might, but I might be dismayed at the amount of material on simple matters like if statements.

This is a pity, as the book probably works better for an experienced programmer, or at least one who has done some work in other languages. The sidebars are usually interesting and technically dense, delivering maximum information in limited space.

I think my main problem with the decision to deliberately split the readership into two target audiences is that I've seen it done better. For example, as mentioned above, Learning Python is probably the main competing title. It too addresses both the novice and experienced programmers, but does so in a much more transparent way. Rather than prefixing sections with "Advanced topic," thus alienating some readers, the more natural box-out approach is used. This gives a much less schizophrenic feel to the text, with the reader able to read the box-outs as and when they feel interested and able to understand the material. When reading Python Programming with ..., I sometimes felt like I was being directed in what to read.

I've been quite negative about this split up to this point, and would like to emphasize that the latter part of the book doesn't really suffer from this problem. Once assured that the new programmer has the basics under his belt, the text assumes a much more natural flow, with the standard optional box-outs. However, I should say that some of the material in the later chapters is non-trivial, and the smoother presentation of the more difficult material leads me to suggest that the author would have been better served by targeting the experienced programmer alone.

Let's look at the publicity blurb and contents in more detail:

The goal of this 'first of its kind' book is to teach new programmers some of the basics of Python programming. Using skill-based exercises and interactive programming sessions, it helps new programmers develop an understanding of concepts and practical techniques. For experienced programmers, the book demonstrates Python's breadth of capabilities and demonstrates the ways that Python interfaces with the Java APIs for professional application development.

Topics include:

  • Fundamental programming concepts, including statements, expressions, interpreters, and compilers.
  • Python basics, including operators, string formatting, namespaces, classes, errors, and exceptions.
  • Object-oriented programming concepts.
  • File input/output.
  • Python's intrinsic functions.
  • Formatting, parsing, and manipulating strings.
  • Interfacing with the Java APIs and working with Java Streams.
  • Using Python and Java Swing to create GUIs.
  • Working with SQL and JDBC.
  • Python and Java applets."

This is a fair representation of the contents. As you can see the poor new programmer is soon expected to work with some non-trivial examples, with the streaming, database and applet sections all being welcome. The material presented particularly benefits from the fairly long example applications.

In addition, I feel that the appendices are interesting and worthy of mention.

  • Installing Jython on Windows
  • Installing Jython on Linux.

    Both installation guides are comprehensive and ensure that installation of the language itself shouldn't present any barrier to the novice, or those who are used to having a sysadmin install their work environment.

  • The Power of Scripting.

    This is a nice section discussing the blurry distinction between programming and scripting languages, why you might want to script and use Java at the same time, what alternative languages are out there, and why the author feels Jython is interesting and useful.

  • Java and Python: A Comparison

    This is an interesting section driving home why Jython is a nice alternative to Java for some applications. It presents some mini-applications, weighted towards Jython's end of the toolbox. They are a small GUI application, a statistics application and some string parsing.

  • Regular Expressions.

    A decent workshop on Jython's regular expression facilities.

Oh Editor, where art thou?

I know that having a few mistakes is unavoidable, but there are a few howlers that slipped past the editing process. I particularly dislike this in an introductory book as it causes confusion in the reader and impedes his absorption of the material.

Some of the errors are typographical, and more than a few involve tabbing in code samples. Normally this would be merely irritating, but forgivable. Unfortunately, the significance of tabbing in Python makes this a much bigger problem for the novice reader!

There are also some properly editorial errors. As an example, the first time we see a user-defined function is in Chapter 4, on control flow. One of the canonical examples is wheeled out, a function to return (min, max, range) given a sequence of numbers.

This example is a nice one and is a good indication of why I generally like this book -- it has the user working with collections and mixed types right from the start, doesn't make a big deal out of defining a function, and includes a nice little box-out on efficiency. It also jumps right to a discussion on intrinsic operations and making sure to use them as they're more efficient and well-tested. It also blows up right after that, confusing the name of the argument list with the intrinsic function name and the name of the rewritten function. I wasn't able to untangle the paragraph until I saw the code. Bad editor, no treats!

So, is this book any good?


Python Programming with the Java Class Libraries is a well above average introduction to using Jython, best suited to interested readers already possessing some Java experience and a decent computer science background. It doesn't hesitate to tackle more complex topics, often with significant amounts of code (good thing), and the author demonstrates a wide knowledge of the field with many interesting box-outs often leading to further reading.

Readers completely new to the programming field will still find this book useful, but may well be intimidated by the advanced material scattered all over the first few chapters and the steep learning curve.

If that is the case, I would recommend that they stick with something like Learning Python should they wish to learn Python specifically, or any of the many other introductory texts on the market if they don't.

Those new to the field who choose to stick with this book will find that there is sufficient advanced material to ensure that the book remains valuable to them for some time to come.


There are two things I'd like to make clear:
  • I did not pay for this book. I was given a review copy by the nice people at Addison-Wesley publishers. The author put my name on his list following a review of his previous title. This was decent of him as my previous review had some negative comments.
  • I'm not a experienced Python developer. My background is C++ and J2EE. A more experienced Python user may have additional issues with the coding style presented. I did not feel particularly able to judge beyond the basics.

You can purchase Python Programming with the Java Class Libraries from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

This discussion has been archived. No new comments can be posted.

Python Programming with the Java Class Libraries

Comments Filter:
  • by krog ( 25663 ) on Thursday August 15, 2002 @11:05AM (#4076968) Homepage
    ...because few people have programmed in Python enough to become comfortable with it. Unlike technical books for C or Perl or Fortran, in which most of the audience may be assumed to be 95% comfortable in the language, books for fringe programming languages must be a little more down-to-earth.
    • by Anonymous Coward
      Fringe programming language? Python? Puh-leeze. Python has the cleanest, most simple syntax of any full featured language I've come across. If you know any of the languages you mention, you shouldn't have any problem understanding 95% of python. A few things like list comprehension or some of the functional programming constructs may be strange for complete newbies or those who haven't seen things like that in other languages, but on the whole, the language is definitely not difficult. In fact, there's a little saying that python is executable pseudocode. It's true.
  • Wait. You mean that there are people still using Python? I thought Parrot was supposed to be the be-all-end-all? :)
    • Some people (as me) do not like Perl...
      for example for its global variables and weird (IMHO)
    • We use python in an application that does database syncronization, and it's a godsend. Now, we just distribue the java code to people, and if they want some specail, fancy translation done, just write a python script. This relieves us for having tons of one-of java code that we have to manage on top of bug fixes. This means that we develop one application that we have to control the source of, customize the hell of it with jython, and only have to release one verision to all of our customers. That's powerful.
  • That's a problem with, oh, I don't know, 99% of the programming titles (O'Reilly excepted) out there.

    Btw, there is an O'Reilly book, Jython Essentials [oreilly.com], on the market.

  • by Anonymous Coward on Thursday August 15, 2002 @11:18AM (#4077068)
    that Python and Java might not be languages that members of the moral community want to be using. Python is an open source language, which means that every time you use it, you are denying revenue to a company that markets other languages. This, in light of 9/11, is pretty sick.

    Java, on the other hand, is a proprietary language, but there are several free VMs and SDKs available, which puts it pretty much on the same page as Python. Also, Java is made by Sun, which is a competitor to Microsoft. MS is a big portion of our economy. Do you want the baby boomers to be able to retire in style, or do you want them to live in squalor and eat out of garbage cans? Because if people keep using Java and Python, that is exactly what will happen.

    There are technologies such as ASP and C# and .NET available. Please use them.
  • by BigJimSlade ( 139096 ) on Thursday August 15, 2002 @11:18AM (#4077069) Homepage

    I just picked up "Jython Essentials" [oreilly.com] from O'Reilly. It does a good job from the perspective that you already know some Java, and want to learn the basics of Python and how to integrate your Java classes.

    As for the language itself, I think it would be extremely usefull for rapid prototyping of UIs if you're working with Swing (and aren't already using a GUI builder). It's nice to have the interactive interpreter so you can see your changes right away.

  • I have the following book-cover rules: . . .

    Proving once again that you can judge a book by its cover.

    For the most part, I use similar "cover rules" when book-shopping. It is possible to get burned by a sub-par O'Reilly book, but they are for the most part excellent.

  • by dpilot ( 134227 ) on Thursday August 15, 2002 @11:27AM (#4077148) Homepage Journal
    I wonder how many copies of this book will sell at the University of Waterloo, in Canda?

    See "Microsoft Invests in the University of Waterloo": http://slashdot.org/article.pl?sid=02/08/14/202925 5&mode=nested&tid=146
  • by kubrick ( 27291 ) on Thursday August 15, 2002 @11:44AM (#4077268)
    I think I'd go with the O'Reilly title here if I was a novice, I mean, doesn't "building Web and Enterprise Applications" sound a little ambitious? Would a new programmer even understand the sub-title? (I've been working for over four years and I'm still not sure what exactly Enterprise is supposed to mean!)

    It means, of course, that you are developing software to power the computers on the Starship Enterprise. This is a very large programming task, which is why we are giving ourselves hundreds of years lead time.

  • by IamTheRealMike ( 537420 ) on Thursday August 15, 2002 @11:54AM (#4077357)
    I'd love to see the open source langauges get together and start sharing class libraries. I'm secretly hoping that Parrot will make this possible, but how do you consolidate all the Python/Perl/PHP/Ruby code libraries together?

    One of the best things about .NET is that there is 1 class library, so you don't get people constantly reinventing the wheel in language X. I think it's actually pretty ironic that despite virtually all the code in Linux being open, we still lack a good way of sharing that code between languages other than binding it to C and then to other languages manually (yuck!).

    • If you consider C++, then there are compatibility problems even within languages. People complain extensively about MSFT, but one thing they have been very good is providing the a fairly practical solution to binary compatibility. You mention .NET, but that is of course in some ways an evolution from COM. There are equivalent and arguably better solutions under Linux, but really, how often do people talk about developing components in CORBA, etc?
  • Ignore everything with a cluttered cover. If I find the cover confusing, I doubt the content will be better.

    Don't judge a book by its cover! You can still learn much from a book where the cover artist got a little overzealous.
  • strangely (Score:2, Interesting)

    This is going to be very useful for me, and it would probably be a valuable guide for someone learning how to program too, having both a more simplistic language moving onto a more compilcated one. So covering many programming topics. Strangely enough, last night I had just downloaded and started using jython, but was discouraged a lot by the poor documentation. Now I wake up and see this. This wouldn't be the first time I've thought of something and then seen it on slashdot the next day.

Things equal to nothing else are equal to each other.