I recently started learning Python and came accross the term Jython. From the Google search results, I thereby concluded that it is indeed a very important term. What is the experience programming/coding using Jython?
3 Answers
Jython is just an implementation of the Python interpreter that runs on the JVM (Java Virtual Machine).
What is JPython?
JPython is an implementation of the Python programming language which is designed to run on the Java(tm) Platform. It consists of a compiler to compile Python source code down to Java bytecodes which can run directly on a JVM, a set of support libraries which are used by the compiled Java bytecodes, and extra support to make it trivial to use Java packages from within JPython. JPython has been renamed and superseded by Jython.
So coding in Jython is the basically same as coding in Python; with the advantage of having access to Java libraries.
Read: Jython FAQ, Why Jython?

- 1
- 1

- 83,810
- 28
- 209
- 234
It's not just about the advantage of having access to the Java libraries. It's also being able to run on Java VM's with all their support and optimizations (i.e. JIT compilation).
Jython is also very usefull for scripting Java applications.
IronPython is a similar approach for the .NET CLI

- 16,341
- 4
- 43
- 57
My recommendation to you: Forget about Jython and IronPython. Nobody uses them except the beginners and their developers. As for Jython, it's much slower, less robust, and less reliable than Python (aka CPython). It doesn't have the significant number of "batteries" that come Python; moreover, threading, process, and other lower-level inner-workings are different, resulting in subtle and hard-to-debug bugs.

- 3,003
- 4
- 29
- 41
-
1Well, i was just curious to know whether there are any real-world applications of Jython. – Aug 28 '10 at 15:51
-
7-1 "As for Jython, it's much slower, less robust, and less reliable than Python (aka CPython)" That's ridiculous and anecdotal at best. It's been years since Jython was slower than CPython. Jython is at least as fast as, if not faster than CPython. – NullUserException Aug 28 '10 at 15:58
-
1@Insanity If you want a real garbage collector (rather than reference counting), which scales a lot better, and access to a wide array of resources with the Java libraries, use Jython. – NullUserException Aug 28 '10 at 16:02
-
2-1, I regularly use a big java application that uses Jython to allow writing scripts for that application in Python. The embedding part is the big strength of Jython. And for "batteries", you don't get the Python libraries, but you get the Java ones. – Mad Scientist Aug 28 '10 at 18:46
-
@Fabian "you don't get the Python libraries, but you get the Java ones". Yeah right -- libraries suited *for* Java with no particular advantages to Python. LOL – OTZ Aug 28 '10 at 22:22
-
@NullUserException "Jython is at least as fast as, if not faster than CPython." Now you are starting to sound like a devoted believer. Hello? Jython runs on JVM. What you think? Execution of bytecode on JVM is somehow faster than the native machine code on real CPU? Give me a break. – OTZ Aug 28 '10 at 22:30
-
1CPython is far from native machine code, but both, CPython and Jython are python, and that is the important part. Speed is not one of the advantages of Python. – Mad Scientist Aug 28 '10 at 22:50
-
2@Fabian NO. Jython runs on JVM, a particular version of which in turn runs on a CPU while CPython, a compiled machine code on a particular CPU architecture, runs on a CPU without JVM. That's the big difference. Since CPython "interprets" python code or pyton bytecode, execution becomes slower than, say, C. But it is almost all the time faster than Jython. Understood? – OTZ Aug 28 '10 at 23:03
-
1@otz CPython is also interpreted, but CPython has no JIT. I wouldn't bet that CPython is faster than Jython. And if you care about performance, Python is the wrong language. For typical use cases of Jython (e.g. embedding in a Java application), performance just does not matter. Which scripting language would you use inside a Java application? Jython is a perfect fit for that case. – Mad Scientist Aug 28 '10 at 23:14
-
@Fabian READ MY COMMENTS. You haven't understood a thing. Also, as for that JIT thing, python dynamically compiles original Python code. Just because you use Jython doesn't necessarily make it superior to others. I'm sorry Jython doesn't have many users, support, documentation, a sophisticated set of libraries, and CPython speed, but that is the reality. You can keep using it if you want, but it comes nowhere close to Python's maturity and convenience. – OTZ Aug 29 '10 at 00:13
-
@otz With a hot JVM, Java is usually faster than C/C++. Java scales better too. Sure, you can write C/C++ code that's faster than Java code. But programmers who are able to do that are very, very few. And the resultant code is much messier too. – NullUserException Aug 29 '10 at 00:19
-
@otz Benchmarks have shown that Jython beats the crap out of CPython, especially when the datasets grow larger (thanks to Java's GC). Just look for them. (it has to be a recent one though, because Jython used to be a lot slower - not anymore) – NullUserException Aug 29 '10 at 00:21
-
2See the benchmarks [here](http://www.smallshire.org.uk/sufficientlysmall/2009/05/22/ironpython-2-0-and-jython-2-5-performance-compared-to-python-2-5/). Mind you they are a year old, right now Jython is probably way better. The same thing happened with JRuby: it used to be slower than native Ruby, now it's faster. The JVM pwns C. Related: [How can JVM implementations like Jython and JRuby beat their native counterparts?](http://stackoverflow.com/questions/3488675/how-can-jvm-implementations-like-jython-and-jruby-beat-their-native-counterparts) – NullUserException Aug 29 '10 at 00:25
-
@NullUserException The benchmark only shows that CPython is faster than Jython in general. No? What's a "hot" JVM? I'm kinda disappointed that the benchmark doesn't even include PyPy and tests only a tiny fragment of computation types. It is vastly incomplete at best. – OTZ Aug 29 '10 at 00:35
-
@otz Yeah, CPython does alright until your dataset grows large - that's when the JVM's garbage collector kicks CPython's behind. Well, complain all you want, at least they bothered to perform benchmarks before spewing baseless assumptions like "Jython is much slower CPython". You are free to do your own benchmarks. – NullUserException Aug 30 '10 at 01:43
-
Java is a proven and enterprise-trusted piece of software. Hating on Java is just stupid. The "Java is much slower than C/C++" myth is one that just won't die in spite of overwhelming evidence of the contrary. Examples: [this](http://www.idiom.com/~zilla/Computer/javaCbenchmark.html), [this](http://kano.net/javabench/), and [the google search I used to find them](http://www.google.com/search?q=java+vs+C) – NullUserException Aug 30 '10 at 01:53
-
@OTZ Alex Martelli thinks [IronPython is fine](http://stackoverflow.com/questions/1905023/is-ironpython-usable-as-a-replacement-for-cpython/1905168#1905168). If even IronPython gets a stamp of approval, I'd bet Jython, which is a more mature project will too. – quantumSoup Aug 31 '10 at 03:09
-
1Benchmarks are not good indicators of performance, but it is irrelevant which one is faster anyway, as the latest Java/Jython is fast enough in most use cases, especially if it is server based application. For us, we have used it successfully for the past 5 years, giving us use of libraries from both Python and Java world, often seamlessly. – Ron Sep 04 '10 at 19:21
-
2The irony here is that so much effort was spent arguing for/against Jython, when actually all that needed to be said was that learning Python was learning Jython. Once you've lerned the underlying language, it's a relatively small step to use Jython (with java) or even IronPython (with .Net). As other commentors above, I'm in a team developing a large java application which with an embedded Jython interpretter, and I wish I'd known about IronPython when I was developing large C# apps, where an embedded scrypting language would have been invaluable. It's all a matter of horses for courses. – Mark Booth Dec 03 '10 at 18:30