5

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 3

14
+150

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?

Sign up to request clarification or add additional context in comments.

Comments

4

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

Comments

-8

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.

19 Comments

-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.
-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.
@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?
See the benchmarks here. 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?
The 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.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.