Why Jython?
As programming languages go, Python is beautiful, elegant, fun, powerful, concise, and easy to learn. Python is written in C, but Jython is a version of Python that is written in Java. This means that you can write a program using Python, which has all of the niceness of Python, but also has access to class libraries that are available in Java. Remember, Java is both a language and a platform, which supports many other languages, including Ruby, Lua, and many others.
Python is popular, and widely used. It comes installed on the vast majority of popular Linux distributions. It runs on Windows. And, and the latest version of Jython not only allows you to use Java libraries, but it also allows you to use popular Python based frameworks like Django, a Python based alternative to Ruby on Rails.
The development of Jython is being undertaken by Sun, which bodes well for its future development.
Why DB4O?
After years of using databases any time I needed to persist information, I have finally rejected that appraoch. One day, will working with an elaborate library of objects that hid the database from programmers, I realized that it would be a lot less work if I could just persist the objects as-is. My code would look pretty well the same, but I would not have to maintain a web server or write stored procedures.
Less work is always a good thing, especially if you lose nothing in the process. DB4O is fast, and it saves objects to the file system – that’s just what I thought I needed. I looked at other products, but DB4O is the leader as far as I am concerned.
Why DB4O and Jython?
There are many reasons. One is that Jython allows you to write less code and to be more productive. Another is that it is not possible to use DB40 with Python unless you willing to use Jython.
Personally, I am attacted to the idea of using DB4O to persist objects with the Django framework. Django, an alternative to Ruby on Rails, will run on Jython. I do not anticipate being able to find the time to dig in to this problem. What would be required is an Active Record like wrapper around DB4O. I would be inclined to develop something that looks as much like Django’s data modelling framework as possible.
The first thing to be aware of is that DB4O persists Java objects, but it does not persist Python objects. Therefore, as you use DB4O with Jython, you need to define the classes you want to persist in Java. I usually put these classes in a JAR, and place them in my Jython classpath.
In an upcoming blog entry, I will use some of the DB4O samples and implement then in Jython. I will show you how to define the classes and create JARs using the Eclipse IDE. You can use Netbeans if you like, but I only have time to provide examples using the tools I commonly use.
Then I will show you how to use Jython to work with objects that have been persisted using DB4O. I hope to show you that you can do this in less time using Jython because you are writing less code. Where I can, I hope to showcase the features of Python that can make working with DB4O more fun.
Join In, If You Wish
If you become interested in these examples, please feel free to correct me or to offer better solutions. I will be sure to give you the credit. If you decide to extend Django for Jython using DB4O, I will participate where I can and provide whatever help I can. I can provide some space on a server for a web site, but you have many other options.
[...] Jim Cassidy (http://www.jimcassidy.ca/about/) in his effort to use db4o together with Jython (http://www.jimcassidy.ca/2008/10/23/db4o-with-jython/). He proposes an an Active Record like wrapper around db4o.Stay tuned to his blog [...]