Tuesday, September 22, 2009

Client Side Google Protocol Buffers & GWT

I have implemented a, crude, but working 'complier' to turn Google Protocol Buffers into GWT ready
java. It uses the base from the google code project here ... http://code.google.com/p/protobuf-js/, which I translated to Java so it could be included and complied by GWT (I added the ability to parse floats as well).

To test I accessed ~3500 protocol buffers and parsed them on different browsers (each containing a String and ~7-10 floating point numbers). I found varying results...

Chrome: ~2500ms
Safari: ~2800ms
FF: ~18,000ms
IE: ~72,000ms (stellar)

... this result had to use event chaining as to not choke the browser (FF & IE).

With such variation in parse time, this was not a reasonable solution. Parsing the protobuffers server side and sending them in JSON turned out to be MUCH faster. With all browsers having a reasonable JSON parsing time (under a second).

For the optimal solution I just modified my 'compiler' to spit out GWT overlay classes for the JSON instead of the proto classes. I then send the JSON wrapped up in a GWT-RPC. All works great now, very snappy performance.

Wednesday, March 25, 2009

GWT Products

Here is my first round of GWT Products.....

http://www.atlas.ca.gov/view/gallery.html
http://www.atlas.ca.gov/download.html
http://justinmerz.homeip.net/swim/gwt/RemoteCeic.html
http://projects.atlas.ca.gov/ (the embedded project search)

... with a couple more in the works ...

Couple notes, inserting as an embedded 'widget' can be interesting. Moreover, when you have a template w/ xhtml doctype or want your gwt code to exist in a different directory than the sites code. I have a simple solution using a $wnd variable for imgs. Looks something like this....

<script type="text/javascript">
var gwtRoot="themes/atlas/gwt/";
</script>
<script type="text/javascript" language="javascript" src="themes/atlas/gwt/gov.ca.ceres.gforge.ProjectSearch.nocache.js"></script>

<div id="ProjectSearch"></div>

.... now I can move my code wherever I want.