Does anyone have any direct experience (good or bad) using Jython with Google App Engine?
-
Added bounty on 24 Jan 2011. If someone has newer info on Jython, examples in use on appengine,source code, tutorials etc. please post – abel Jan 24 '11 at 09:58
2 Answers
To ask the obvious question: Why would you want to? (C)Python is supported natively by Google App Engine, and by now is fairly mature and very well supported.
To answer the original question, though: I don't have personal experience, but I can give you a general overview of what it'll be like:
The easiest way currently will be to use Jython's support for calling into Java to use the App Engine Java SDK. This means that although you'll be writing Python, it's going to look a lot like Java, and you'll have to use the Java docs, rather than the Python one.
It is, however, theoretically possible to use the Python SDK in Jython on App Engine. The SDK is pure Python, and all the interaction between the SDK and the runtime is done by way of RPCs though the google.appengine.api.apiproxy_stub_map module. Java has an equivalent interface in the com.google.apphosting.api.ApiProxy class - see the article on Unit Testing in GAE for some details on how to configure it.
Given all that, here's how you could use the Python API in Jython:
- Write a Python apiproxy_stub that simply takes all API calls and sends them to the com.google.apphosting.api.ApiProxy class.
- Bundle the relevant parts of the Python SDK with your Jython app (that's most of it, unfortunately).
- In your initialization code, install the apiproxy_stub subclass you wrote as the handler for all the relevant services - datastore_v3, memcache, user, urlfetch, and images.
If you do end up doing this, please document it and release the code - I know of at least one other user who would be interested. :)

- 100,655
- 16
- 128
- 198
-
5Jython can directly interoperate with Java, JRuby, etc, etc, and gives you access to a very different set of libraries and tools than good old CPython, so Thomas' question sounds quite sensible to me (unfortunately I don't have the experience he asks for, so I can't answer his question, but I hope others might). – Alex Martelli May 02 '09 at 17:05
-
A couple of reasons: one is that I have been approved for the Java runtime by Google and would like to leverage some of the Java code that I've developed over the past 9 years, and the other is that I believe that Python (Django) Web development makes more sense and has more of an existing community and code base than Java (JSP).. Seriously, are those not sound reasons to "cut it down the middle" and (rather than choosing Java or Python) use Jython? TL – May 02 '09 at 17:23
-
Well, I would still suggest using Java, if Java is what you want. :) – Nick Johnson May 02 '09 at 21:09
-
1
First, there are people who claim that Jython, Querces, and JRuby can Beat their Native Counterparts when it comes to speed, utilizing the power of the JVM.
However, there is some conflicting information on the speed of Jython. A Stack Overflow user claims that Jython is the slowest of many of the languages involved in a speed test he conducted.
Neither of the performance questions really involve App Engine, just the JVM in general.
In this article posted by a Jython committer, Alan Kennedy claims that Jython on App Engine combines the rapid-development nature of Python with the bountiful libraries available in the JVM. Jython is Python, but it's Python that has direct access to Java classes.
I have some experience with this with Querces PHP. I ported the JQuery Form Builder plug-in to Google App Engine. It's PHP code, but that PHP is able to directly access DAO objects that were written in Java. Likewise, Jython is able to do the same.
Alan Kennedy also met a Challenge issued by Nick Johnson whereby he demonstrates something that can be done with Jython on App Engine that would otherwise be difficult to accomplish in pure Python, XSLT transformations. He answers the strike-through question in Nick's answer: Why would you want to?

- 1
- 1

- 33,636
- 11
- 99
- 120