Jython 2.0 Goes Beta01/03/2001
On December 31st, Jython developers Barry Warsaw and Finn Bock announced their first beta of Jython 2.0. Jython is a pure Java implementation of the Python interpreter. Jython gives you Python on the Java Virtual Machine. That means access to Java classes.
Why two interpreters? Essentially because they are for two different machines, the actual machine and the Java Virtual Machine (JVM). The virtual machine is how Java achieves platform independence. Different machines and operating systems have their own rules for how a program should run, making it difficult to run one program anywhere. The Java solution is to make the machines all look the same by creating a virtual machine that runs inside the actual machine.
Having only one machine to write for makes portability of 100% Java programs easier. Unfortunately, it makes other things harder. Programs written for the virtual machine cannot use libraries written for the native system directly. They can be integrated using the Java Native Interface, but that ruins portability. For a portable solution, the library must be re-implemented in Java. This is seldom practical. Jython inherits this same constraint. Many extension modules for Python are written in C and cannot easily be used by Jython. Conversely, Jython programs that rely heavily on Java modules may be impossible to port back to Python. Platform independence through the virtual machine carries a price of segregation.
While Jython doesn't solve the segregation problem, it does let you take advantage of Java libraries directly. There is a lot of great code available in Java. Unlike using C modules, which must be specially prepared (wrapped) for use by Python, Jython can directly use any Java module as is. Java programs can be passed to Jython modules just as easily. You can also leverage Python's strength as a rapid development language, embed the Python scripting language in your application, or experiment with Java classes from an interactive prompt. Jython brings the power and flexibility of Python to the virtual machine.
Jython 2.0 is the successor of JPython. After a long fallow period, this project is now on the move. Jython 2.0 improves compatibility with Python 2.0, adding features like list comprehensions, extended call and print statements, augmented assignment, and formatting for long values. It also incorporates the free Apache Jakarta ORO regular expression modules. If you work at all with Java, or would like to in the future, you should definitely try Jython.
Stephen Figgins administrates Linux servers for Sunflower Broadband, a cable company.
Read more Python News columns.
Discuss this article in the O'Reilly Network Python Forum.
Return to the Python DevCenter.