tags:

views:

83

answers:

3

Hi,

As a summer learning experiment, I'm thinking of coding up a web front end for a trading game i wrote in python, that generates share prices and random snippets of text.

I am sort of struggling with how this should work on the back-end though. I'd rather have my GWT client page interact with the python share price generator, than to try and re-code it in java. I suppose i could use an sqlite db, and then use jdbc to pick up the prices, but i was wondering if there is a better way, for me to be able to poll some python script either from my client page, or from the serverside java code ?

I found this python wrapper, but i'm not sure how i could use it though: http://code.google.com/apis/visualization/documentation/dev/gviz_api_lib.html

Thanks.

A: 

Make no mistake, GWT is a Java technology. You could perhaps interoperate by using Jython to compile your Python code but your UI will basically need to be written in Java (wrappers are second class citizens here). The reason is that the RPC protocol is proprietary and even though GWT is open I believe the compiler that takes the Java source and creates the Javascript (including the RPC calls) isn't.

With Python you might be better off using an RIA Javascript framework like Yahoo UI (YUI), ExtJS, etc. Uki also looks interesting. To give you an example of Uki, here is google Wave layout in 100 lines of Javascript.

cletus
interesting - i know next to no js though, perhaps I should just push on through with the java / gwt thing and use a central db to talk b/w the python code and java... just seems like some serious over-engineering though :)
sadhu_
@sadhu it is (over-engineering). Javascript is pretty easy and I think you'll prefer the end result with Javascript+Python vs GWT+Java+Python, which will be far more complex. Writing GWT apps is non-trivial too.
cletus
Thanks Cletus - final question (i promise) i'm leaning towards jQuery now, after what you and Alex have to say but I know from experience that GWT's rpc calls were super reliable, and you could ping it from a couple of browsers simultaneously every second and it would still work. Do you forsee this being a prob in a JS based system (and me being a somewhat new python coder?)
sadhu_
@sudhu on the browser all JS code is singlethreaded so that side isn't an issue. On the server, it depends entirely on how you code it. Python scripts run independently of each other so you should be fine there so long as you don't lock any shared resources overly long (eg PHP sessions are locked while open).
cletus
A: 

I second @cletus' recommendation to go for real javascript plus a JS framework (though as the framework I'd suggest any of jquery, dojo, or google closure -- sorted in order from low to high "formality" -- but I guess that's a question of taste).

If you want a Python-based GWT-like approach, try pyjamas -- but it's not as rich and mature as GWT, so, unless your browser-side needs are really very modest, JS + framework is just a better approach.

Alex Martelli
A: 

Yes you can. Using JSON, you can basically use whatever back-end language you want with GWT. See this page for more detail.

GWT is a powerful tool but nonetheless a complicated one. If you take the time to learn how to use it efficiently, you'll be rocking your way through building you front-end code. You'll also find the Google plugin for Eclipse to be quite a joy.

Zwik
interesting - i've just installed it and playing around with it now - thanks for the heads up man!
sadhu_
my pleasure! By the way, if you like the answer you've received from anyone, you can vote it up! ;) Welcome to StackOverflow!
Zwik