Saturday, October 18, 2008

Java to Python conversion

Pyjamas is for python, what Google Web Tooklit is for Java. Pyjamas takes python code and some widget libraries and runs it through a python-to-javascript translator. The result: Coding web appliations has never been easier! JSON calls and event handling is a breeze. Little projects that I've attempted doing in the past, using libaries such as jquery, have left me writing a lot of javascript by hand, which get's ugly.

While I absolutley love pyjamas (and gwt for that matter), I really like the looks of extjs. The good news is that they have come out with extjs-gwt, which is "a Java library for building rich internet applications with GWT."

In talking with some of the folks on the pyjamas mailing list, I've gathered that the process of making pyjamas involved hand-converting the java libaries (ie widgets) of gwt from java to python. (If you look at the source code of both pyjamas and gwt, you can see that it's a pretty straight-forward conversion).

Surprisingly, pyjamas is only about 8000 lines of source code, which is relatively long. Extjs-gwt, on the other hand, as one person on the mailing list commented, has over 33,000 lines of java code in widgets alone!

The task of hand-translating extjs-gwt would be daunting.

I'm currently investigating the possiblity of writing a java to python converter to at least help out with the translation. A google search let me to a blog post which led me to an unmaintained project called java2python.

Because I'm personally interested in the workings of such technologies, and because I couldn't get java2python to work, I've decided to write my own translator.

I found a great article by the author of antlr (the same lexer/parser/tree_generator that java2python uses) on how to do such a translation between languages.

I hope that my efforts prove fruitful!

4 comments:

Robert Comstock said...

Count me in

Sin said...

I suppose it should be possible to map a lower level language to a higher level one, as a lot of stuff can simply be ignored, but the code would look quite bad.

me said...

You can have a look at my yava2python project.

Cristian Salamea said...

I want to participate with this project.
I think the best way will be study extjs-gwt than java2python conversion.
Port the library is for me the best solution.
If decide begin the project, count with me.

Pyjamas