Supplemental files and examples for this book can be found at http://examples.oreilly.com/9780596002473/. Please use a standard desktop web browser to access these files, as they may not be accessible from all ereader devices.
All code files or examples referenced in the book will be available online. For physical books that ship with an accompanying disc, whenever possible, weve posted all CD/DVD content. Note that while we provide as much of the media content as we are able via free download, we are sometimes limited by licensing restrictions. Please direct any questions or concerns to .
Foreword
The purpose of a programming language is to let software developers express their intentions as simply and directly as possible.
The story of Jython begins one summer in Ashland, Oregon. I was juggling in a park behind a theater when I met Pavel Curtis, a scientist at Xerox PARC, who wanted to pass clubs. While we were juggling together, he told me about a wonderful new programming language called Python. Writing code in Python felt like writing the sort of natural, informal code that developers would use when they wanted to share ideas quickly. It was executable pseudocode.
In addition to telling me about Python, Pavel gave me some advice on what would make for an interesting computer science research project. He felt that the most interesting projects were those that dealt with groups of people working together rather than individuals working in isolation. Open source projects have proven the power of groups of people spread all over the world working together.
The story of Jython begins with the pain of finishing my masters thesis at MIT. In that thesis I fabricated, measured, and analyzed superconductor-semiconductor junctions as potential building blocks for a quantum computer. For analyzing the measurements and comparing them with theory (the Bogoliubov-deGennes equations), I used matlab extensively. Matlab is a wonderful language for a wide range numerical analyses; however, it is a terrible language in which to do anything else. In order to overcome its shortcomings, I eventually cobbled together a hodge-podge of C, Python, and matlab code to produce my final results.
I knew there had to be a better way. After finishing my thesis, I started to work on an extension to Python to support numeric analysis as naturally as matlab does, without sacrificing any of the power of Python as a rich, general-purpose programming language. This was the first project where I discovered the power of a collaborative open source community. The contributions of Jim Fulton, David Ascher, Paul DuBois, Konrad Hinsen, and many others made that project much more successful than it could ever have been as an isolated endeavor. It is still thriving now on sourceforge under the leadership of many of the original community members.
The story of Jython begins in the spring of 1997, while I was working on my Ph.D. at MIT. While doing some benchmark work comparing the performance of Numeric Python to a variety of other programming languages, I was amazed to discover that Java was as fast as C code for simple numeric benchmarks. Previously, I had been uninterested in Java because I saw it as an inferior replacement for Python. But I began to see the possibility that Java could be a replacement for the ugly and error-prone C code that I was writing for the performance-intensive parts of my systems.
After a week spent experimenting with Python on Java, Id learned some exciting things. First, it was possible to translate Python programs into Java bytecodes by hand without any significant loss in performance. Second, the Java language had many similarities with Python and was a nice static counterpart to Pythons dynamic nature. Finally, I learned about the wonderful java.reflect package that made it possible to load and use arbitrary Java libraries from Python without having to write any glue code. This meant that it should be possible to download an interesting new Java library from the Net, put it on my classpath, and immediately start using it from Python.
That single weeks worth of experiments convinced me that there was a beautiful and elegant match to be made between Python and Java and I wanted to be the one to do it. So I took an extended hiatus from the Ph.D. program at MIT and started working full time to make Jython real. One week later, Al Vezza invited me to lunch and convinced me that CNRI was the best place to do this work. This gave me the wonderful opportunity to work closely with many of the key Python developers there, including Guido van Rossum himself. The initial feeling of the inevitability of the beautiful match between Python and Java never died. The project was consistently a pleasure to work on. This is a testament to the great people who designed and built both Python and Java.
Guidos sense of the aesthetics of language design is amazing. Ive met many fine language designers who could build theoretically beautiful languages that no one would ever use, but Guido is one of those rare people who can build a language that is just slightly less theoretically beautiful but thereby is a joy to write programs in.
While I never had any direct contact with the developers of Java, they continued to make advances that improved Jython significantly. The addition of the collection API in Java 2 made the integration with Pythons rich collection data types much more elegant. The amazing progress in virtual machine performance from the HotSpot team at Sun meant that every six months Jythons performance would get faster, while I wasnt spending any time on performance optimization at all.
My role in the Jython story ends early in 1999. Once again, it was a researcher at Xerox PARC who told me a story about a wonderful new programming language. This time it was Gregor Kiczales who was extolling the virtues of aspect-oriented programming and AspectJ. His story about capturing crosscutting concerns in modular aspects to solve the persistent problem of tangled source code resonated strongly with me. The fact that he was offering me a chance to move back out to California and to work a few miles away from the Stanford Court Jugglers was only a secondary motivation.