Java Python

Used to be "JPython", more recently changed to "jython".

An implementation of the Python Language as one of the Other Languages For The Java Vm.

from the site ... (some from an older site)

Jython is an implementation of the high-level, dynamic, object-oriented Python Language written in 100% Pure Java, and seamlessly integrated with the Java platform. It thus allows you to run Python on any Java platform. Jython is freely available for both commercial and non-commercial use and is distributed with source code. Jython is complementary to Java and is especially suited for the following tasks:

Embedded scripting - Java programmers can add the JPython libraries to their system to allow end users to write simple or complicated scripts that add functionality to the application. Since JPython is certified 100% Pure Java, it can be added to an application without fear of compromising its ability to run on all Java platforms.

Interactive experimentation - Jython provides an interactive interpreter that can be used to interact with Java packages or with running Java applications. This allows programmers to experiment and debug any Java system using Jython.

Rapid application development - Python Language programs are typically 2-10X shorter than the equivalent Java program. This translates directly to increased programmer productivity. The seamless interaction between Python Language and Java allows developers to freely mix the two languages both during development and in shipping products.


Jim Hugunin began JPython in 1997. He left JPython development in '99. (He later began Iron Python, in 2003.)

"The Story of Jython", by Jim Hugunin

Barry Warsaw succeeded Hugunin, moving Jython onto Source Forge and certified-Open Source licensing. From about 2000 Finn Bock and then Samuele Pedroni took over development. For some time Jython was an important Python implementation and one of the most successful of the JVM languages. But development stalled at some point after 2001. (Pedroni switched his focus to Py Py.) By mid-2007, the stable version of Jython was still at 2.1 while CPython had reached 2.5. The missed point-releases include considerable changes to core Python (including an overhaul of the object model) so Jython not only missed those features but also saw its compatibility with CPython decline. In relative terms, it lost some or all of its lead in maturity over other JVM languages including Jay Ruby, Groovy Language and Scala Language. As of August 2007, Jython may finally be escaping its stall; Jython 2.2 has reached RC3.


Strengths:

Ability to use a scripting language from within Java. This alone makes it worthwhile!

Excellent ability to invoke Java Language objects from Python code. This means that you have easy access to all those Java libraries. In fact, it's often EASIER to call Java objects from the Python side than from the Java side! The only time it gets annoying is when there are multiple methods with the same name but multiple signatures. That's called "method overloading", grasshopper.

Pretty darn easy to invoke Python Language objects from Java code. This less used, but vitally important for complete integration.

All the "obvious" conversions are performed for you. Strings, numbers, arrays, and things like that are typically converted for you with little effort. A java.lang.String just becomes a Python string (and vice-versa) with no need to "convert". With fancier objects you'll need to make some effort.

Python interpreter can easily be embedded in Java. The existence of "exec" (or its equivalent) in Perl Language, Python Language, Lisp Language, etc. makes it quite easy to make things user-scriptable (at runtime). Now you can do it for Java Language too, only the user scripts get written in Python.

Weaknesses:

Class loading is weak. For example, if you change a script, you either need to run it with a new class loader or restart the application that will exec the script. Furthermore, reload is shallow, so if any imported scripts change, they also need to be recompiled and run under a new class loader.

Jython programs run much more slowly than CPython ones.

Jython lags several "point" versions behind CPython, plus it doesn't have all the same libraries and functionality as CPython.

Java arrays are a problem. Use the jarray module for Java array support.


Q.Has Jython any benefits against the Bean Shell? -- Reasonable question actually. Bean Shell, Rhino Interpreter and Java Python all began around 1997, making them "first-generation" JVM languages. (Where clearly Java was the zeroth-generation JVM language. :) ) How do they, or used they, to compare?


See original on c2.com