Python Programming with the Java Class Libraries
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.
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? Yes.
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.
Disclaimer 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.
They're in my hair! They're in my hair!
Your economy is bloated by BIG FAT HARDCORE CAPITALIST PIG !!! The more they grow bigger, the more they want,... and the more they grow bigger... so please shut up ! It's no evil, if they loose some revenue, it will leave some more for the small ones.
"Insanity in individuals is something rare, but in groups, parties, nations, and epochs it is the rule." - Nietzsche