InfoQ

News

Python Web Framework on the JVM

Posted by Craig Wickesser on Jan 19, 2008

Community
Java
Topics
Web Frameworks ,
Open Source ,
Language
Tags
Python ,
Django ,
Jython

Python, a dynamic object-oriented programming language, has been around for quite some time. In its lifetime there have been many web frameworks to choose from (i.e. Pylons, TurboGears, CherryPy, Zope, Django, etc) making it difficult for developers to make a selection as Ian Bicking pointed out,

For a long, long time (longer than most of those frameworks have existed) people have complained about the proliferation of web frameworks in Python.
Recently Django has picked up steam in the world of Python and Java.
Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.

Developed and used over two years by a fast-moving online-news operation, Django was designed to handle two challenges: the intensive deadlines of a newsroom and the stringent requirements of the experienced Web developers who wrote it. It lets you build high-performing, elegant Web applications quickly.

Django focuses on automating as much as possible and adhering to the DRY principle.

On the JVM side there exists Jython,

An implementation of the high-level, dynamic, object-oriented language Python written in 100% Pure Java, and seamlessly integrated with the Java platform. It thus allows you to run Python on any Java platform.
It took nearly 6 years for Jython to go from version 2.1 to 2.2, but in just the last few months Jython has gone through two release candidates and another stable release, currently at 2.2.1. The Jython developers are working hard on producing Jython 2.5 which aims to align Jython with CPython 2.5 and provide a much cleaner and consistent code base.
A side goal of Jython 2.5 is to try to get some CPython frameworks working, especially the web frameworks, for example:
  • Django
  • Pylons
  • TurboGears
  • Twisted

InfoQ recently had the opportunity to interview Jim Baker, a python evangelist and contributor to Django on Jython (DoJ), to find out what is expected and when.

What is the expected release date for Django on Jython?

This year. It's predicated on the next release of Jython. See #2 for that planning. Django in contrast just works, with only minor changes, thanks to a lot of work that many other people did in identifying (minor) Jython incompatibilities. Now most of the problems we have identified actually occur only in testing, where Django makes certain assumptions about Python should run that don't apply to Jython. An example of such an assumption that the hash algorithm is the same for dictionary implementations; because we use Java's (ConcurrentHashMap), this is not the case. However, that's an artifact of the testing process, Django doesn't really care about that. Still, we plan to certify this by passing all the tests (fixed as necessary).
What version of Jython is going to be required?
Jython 2.5 - equivalent to CPython 2.5 (or what is conventionally called Python!) is what we are targeting in the Jython project. This is actually moving very fast. We have a 2.5 compiler that's available for experimental usage, but it's getting more and more robust as we have additional people testing it. This "newcompiler" was initiated by a Google Summer of Code project that I mentored. (Bruce Eckel mentioned this in a blog post. We in fact hit that mid-September date!) At the Python Conference in mid-March, we will be setting the specific target based on where we are. Tobias and I will also be presenting our paper "A New Compiler for Jython" at PyCon.
With the release, will there be a simpler install? Currently your blog post suggests applying patches, copying files, etc.
There will be a simple install! My reporting was simply to show how close we were in fact to this goal. I also anticipate plugin support in major IDEs like Eclipse or Netbeans, although this will come later.
Is Django trying to be what Rails is for Ruby and Grails is becoming for Groovy?
Django offers comparable functionality to those web app frameworks, with ostensibly a more robust platform. So Django is written to be multithreaded, unlike RoR, which means we don't have to go through a lot of tricks to make it work on the Java platform, such as using multiple classloaders. We currently have database support for PostgreSQL, with some work done also on MySQL. I helped write the Oracle backend for Django. We're also planning to support Java DB (Derby).
Jim also expressed the usefulness of having a preconfigured stack available, to ease the experimentation of using Django on Jython (DoJ),
I'd like to see the following preconfigured stack available for Django on Jython (DoJ): Derby + Tomcat. This should be something that a developer can just access via a plugin from Eclipse or Netbeans or IDE of their choice, which means they can configure Derby and Tomcat directly from the IDE. It also provides an obvious migration path to other containers and databases. Perhaps more importantly, such a setup allows for easy DoJ experimentation, whether that's for someone building a Django app, or also using tuple spaces, rules engines, PDF tools, or other parts of the heavy-lifting infrastructure available on the Java platform. This is where I think DoJ provides true compelling value.

 

For additional information try the following links:

 

Dynamic Frameworks on the JVM by Kevin Teague Posted Jan 19, 2008 9:35 PM
Re: Dynamic Frameworks on the JVM by Geoffrey Wiseman Posted Jan 20, 2008 8:45 AM
Re: Dynamic Frameworks on the JVM by Jason Lee Posted Jan 20, 2008 3:10 PM
Sun's wakeup call by Zeev B Posted Jan 20, 2008 4:58 AM
great news indeed by Michael Neale Posted Jan 20, 2008 6:06 AM
  1. Back to top

    Dynamic Frameworks on the JVM

    Jan 19, 2008 9:35 PM by Kevin Teague

    Good to see the Jython project moving again! Sun lost an opportunity when Microsoft hired Jim Hugunin, Jython's creator and lead developer, to lead the IronPython project.

    Django is often contrasted with Ruby on Rails, both frameworks having started around roughly the same time and sharing many of the same philosophies and goals. The JVM ports of the two frameworks highlight one of the key differences between the two framework code bases though, as "Rails uses every metaprogramming trick in the book" while the Jython developers chose Django as their first framework to attempt to run on Jython 2.5 as it's coding style is much less magical.

    One of the benefits of using a framework is that key parts can be written in a system level langauge such as C, Java or C#. Unfortunately, as soon as you do this you loose the ability to easily run on different platforms. Python frameworks Zope and Grok for example have large portions written in C, which means that while it can be compiled for different platforms, it can't participate in the CLR or the JVM worlds. Likewise frameworks such as Ruby on Rails or Django are less likely to maintain key parts of the framework in Java since they will have users that want to deploy on CRuby or CPython. You can have alternative implementations in your native language but it places a significant maintenance burden on the framework authors.

  2. Back to top

    Sun's wakeup call

    Jan 20, 2008 4:58 AM by Zeev B

    Congratulations InfoQ - at last an article covering Python and Jython. Being a regular reader to your site I was under the impression that there is only Java and Ruby in the world :-)

    It is good to see that even without Sun's help Jython is moving forward and soon we will be able to run Django on the JVM. This is really exciting news for a developer like me who using both Java and Python on a production system.

    I hope Sun will come to its senses, ignore the hype a bit and start supporting Jython/Python at least by providing some support for it in Netbeans 6 and maybe even supporting the Jython project itself. Maybe they should read the TIBOE Programming Community Index which declared Python the Programming Language of 2007 because of the surge in its popularity rating during the past year. Python and Java share some common values such as code explicitness and a dedicated community with a community process. Python has a lot of strengths that Sun and the Java community could benefit from such as the the highly dedicated Python community, Python's matureness and wealth of libraries and frameworks and Python's prevalence in high profile companies such as Google.

  3. Back to top

    great news indeed

    Jan 20, 2008 6:06 AM by Michael Neale

    Its also good to note that what is good for JRuby is good for Jython as well.

  4. Back to top

    Re: Dynamic Frameworks on the JVM

    Jan 20, 2008 8:45 AM by Geoffrey Wiseman

    Good to see the Jython project moving again! Sun lost an opportunity when Microsoft hired Jim Hugunin, Jython's creator and lead developer, to lead the IronPython project.


    To be fair to Sun, it felt like Jython stagnated long before the IronPython move. It might have just been 'before its time' -- people were less interested in dynamic languages on the JVM in Jython's heyday, and by the time they were, it was outdated.

    Still, nice to see forward momentum.

  5. Back to top

    Re: Dynamic Frameworks on the JVM

    Jan 20, 2008 3:10 PM by Jason Lee

    It is also my understanding (though I don't have time to hunt down my source), that Sun fully intends to support a number of dynamic languages on the JVM. If memory, serves, they selected Ruby (much to my chagrin :) for a couple of reasons: momentum and you have to pick SOMEWHERE to start. See point #1. I imagine Python should soon see some love from Sun, but, obivously, doesn't strictly *need* it.

Educational Content

Brian Marick on 4 Challenges and 5 Guiding Values of Agile Software Development

Brian Marick takes us through a quick tour of the most important values and challenges to adopting Agile successfully (they aren't the typical challenges and values we hear in the community).

Are You a Software Architect?

The line between development and architecture is tricky. Does it exist at all? Is an ivory tower actually needed? There's a balance in the middle, but how do you move from developer to architect?

Agile – A Way of Life and Pragmatic Use of Authority

The word 'authority' sometimes produces an allergic response in hard-line agilists. Freedom and authority – both are bad if misused and both are good if used in right spirit for a noble cause.

Getting Started with Grails, Second Edition

"Getting Started with Grails" brings you up to speed on this modern web framework. Companies as varied as LinkedIn, Wired, and Taco Bell are all using Grails. Are you ready to get started as well?

Using ITIL V3 as a Foundation for SOA Governance

Those familiar with only ITIL V2 often scoff at the thought that ITIL could serve as a governance framework for SOA. With ITIL V3, the focus of the framework shifted towards service-orientation.

Adrian Colyer on AspectJ, tc Server and dm Server

SpringSource CTO Adrian Colyer discusses AspectJ, SpringSource's dm Server and tc Server products, OSGi and Scrum.

Adam Wiggins on Heroku

Heroku's Adam Wiggins talks about Rails, Background Jobs, Add-Ons, Ruby, and how Heroku manages to work around Ruby's inefficiencies using Erlang and other languages.

SOA as an Architectural Pattern: Best Practices in Software Architecture

For Grady Booch the foundation of a good architecture is patterns, SOA being just one of many patterns. In this Second Life presentation, Booch attempts to bring more clarity on what architecture is.