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 master’s 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, I’d 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 Python’s 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 week’s 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.

Guido’s sense of the aesthetics of language design is amazing. I’ve 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 Python’s 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 Jython’s performance would get faster, while I wasn’t 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.

The story of Jython as a flourishing open source community really begins after I left to work on AspectJ. Barry Warsaw started the ball rolling by ensuring that Jython was released by CNRI under an officially approved Open Source™ license. Finn Bock stepped up immediately to take over the development leadership on the project. At first his leadership was informal as he developed and maintained the definitive set of patches, later he took over formal leadership as the project was moved to sourceforge. Finn was soon joined by Samuele Pedroni; together they have done an amazing job of both keeping Jython in sync with several major improvements made to the Python language and continuing to improve the core functionality.

Jython has always been a simple and easy-to-use integration of Python and Java. However, since the earliest days of the project, people have complained that the lack of high-quality documentation has been a gaping hole in the usability of Jython. This book finally fills that hole.

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 for you with this book. Here you have all the pieces you need to go out and start using Jython to make your development easier and more productive than ever before.

—Jim Hugunin

Get Jython Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.