Sprinkle Ajax with some scouring powder by Google Gears

In a world of bloated do-everything tools, Google Gears does one thing really well. Ok, three things. Cache and serve application resources, store and query data locally in SQL database, and perform resource-intensive operations asynchronously. From JavaScript! In your Browser! Cross-platform! Spoon!

Google asked me if I wanted to be in on an embargoed news release item earlier today and I said no. Companies never give you enough information in those things, so if you write something early to be the first to post,

you end up missing a feature, leaving something out, or having to go back and re-write the article. At least their embargo times are measured in hours instead of weeks, unlike Sun. But I digress...

Google has announced a nice way to support online and offline web-based applications with the same code using Google Gears. Gears originally had the code name "scour" leading to all sorts of puns in the code and mailing lists with "scouring powder" and so forth. And they say geeks have no sense of humor. I think of it as more of a "holy hand-grenade".

Anyway, the way it works is the user has to install ("ding ding whoop whoop whoop!" I can hear the alarm bells going off already, but wait, it's only 700K and there are no scary questions so pipe down)... ahem. As I was saying, the user installs a little browser plug-in which does three things, no more, no less. Four shalt thou not count, nor either count thou two, excepting that thou then proceed to three. Five is right out. (Hmm, maybe I should lay off the cough medicine). Those three features are:

LocalServer LocalServer Cache and serve application resources (HTML, JavaScript, images, etc.) locally
Database Database Store data locally in a fully-searchable relational database
WorkerPool WorkerPool Make your web applications more responsive by performing resource-intensive operations asynchronously
Forget cookies. Can you say SQL? I knew you could. Here's a snippet of JavaScript that runs a SQL query inside your browser to access a database on your local machine:

   var rs = db.execute('select * from Demo order by Timestamp desc');
var index = 0;
while (rs.isValidRow()) {
recentPhrases[index] = rs.field(0);

I took out the error handling but you can see the whole sample on the Google Gears site, or go here for a demo. It's cross-browser, and cross-platform. And, oh yeah, open source (BSD license; not sure why that picked that instead of the Apache license Greg is so fond of).

Can't talk now, gotta go play some more with Google Gears. Meanwhile, install Gears for yourself, and check out the Samples and Tools zip. Whether you're doing battle with network latency, dealing with occasionally connected users, or putting the nail in that old fashioned office suite with your killer Ajax apps, Gears may be just the armament you need. Google Reader has already been fitted with it - will Mail and Docs and Spreadsheets be far behind? So go now, and "lobbest thou thy Holy Hand Grenade of Antioch towards thou foe, who being naughty in my sight, shall snuff it."