Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is Jython and is it useful at all? [closed]

I know Python, but what is Jython?

  • When will I need Jython?
  • What are the drawbacks?
  • I assume it is slow?

Please detail it out! thanks.

like image 661
TIMEX Avatar asked Dec 07 '09 13:12

TIMEX


People also ask

What is Jython used for?

Jython is a version of the Python programming language that runs on the Java platform. It allows users to write programs in Python and compile them to Java bytecodes that run directly on a Java Virtual Machine, or JVM.

Is Jython still used?

Java. Jython was started by Jim Hugunin in 1997 as “JPython”, and has seen continued development since then. However, development of Jython is remains on the Python 2.7 line, a major release of the Python interpreter which, since the beginning of 2020, is no longer being maintained.

Does anyone use Jython?

Jython can also be used as an embedded scripting language within a Java program. You may find it useful at some point to write something with a built in extension language. If working with Java Jython is an option for this (Groovy is another). I have mainly used Jython for exploratory programming on Java systems.

What is difference between Python and Jython?

Difference between Python and JythonReference implementation of Python, called CPython, is written in C language. Jython on the other hand is completely written in Java and is a JVM implementation. Standard Python is available on multiple platforms. Jython is available for any platform with a JVM installed on it.


2 Answers

Quoting Wikipedia:

Jython, successor of JPython, is an implementation of the Python programming language written in Java.

As for what uses it may have:

Jython programs can seamlessly import and use any Java class. Except for some standard modules, Jython programs use Java classes instead of Python modules.

Performance measurements of Jython, IronPython and CPython show that both Jython and IronPython outperform CPython for some cases with large datasets.

like image 72
Joey Avatar answered Sep 25 '22 01:09

Joey


If you know Python and has bought into the "pythonic" way of doing things, then Jython allows you to bring that philosophy to the JVM stack. If you do this, it is much more than just adding scripting capability.

In our latest projects, all the custom and business logic is built in Jython, at the same time we can still leverage some of the great tried and tested Java libraries like Solr, Jasperreports, Quartz, Jetty, Velocity to name a few.

It does get compiled to bytecode, however, an extra layer is being added, but is no different to using an ORM instead of straight JDBC for example.

What you gain in productivity far out weighs the minuscule lost in performance.

On the server side, Jython is rarely the bottleneck. For mini desktop apps, there may be issues, but very much dependent on what you are trying to do.

The latest JDK, together with containers like Jetty or Tomcat are very mature and stable, adding Python on top, in many cases, gives the best of both worlds.

like image 21
Ron Avatar answered Sep 25 '22 01:09

Ron