Scott Hanselman

Google Gears - Maybe all Rich Internet Applications needed was Local Storage and an Offline Mode

May 31, '07 Comments [26] Posted in Javascript | Musings | Tools | XML
Sponsored By

Stunning move by Google today in the Rich Internet Application space. While most of us (myself included) are off debating Flash vs. Silverlight vs. Apollo vs. Whatever, Google introduces Google Gears...at technology all of the above (or none of the above) can utilize...

This is a huge move and is quite brilliant. In one seemingly innocuous move (and one tiny 700k (yes, 700K) download) Google is well positioned to get Google Docs, including Writely, Spreadsheet and Presentation, along with who knows what else, enabled for offline use. And the whole thing is Open Sourced via the New BSD License.

Here's a snippet of Javascript that is used to detect if Google Gears in installed. Note the three (currently) different ways, one each for Firefox, IE and Safari.

 var factory = null;

  // Firefox
  if (typeof GearsFactory != 'undefined') {
    factory = new GearsFactory();
  } else {
    // IE
    try {
      factory = new ActiveXObject('Gears.Factory');
    } catch (e) {
      // Safari
      if (navigator.mimeTypes["application/x-googlegears"]) {
        factory = document.createElement("object");
        factory.style.display = "none";
        factory.width = 0;
        factory.height = 0;
        factory.type = "application/x-googlegears";
        document.documentElement.appendChild(factory);
      }
    }
  }

To the right is a dialog box that pops up to let you know that Google Gears is going to store data locally. Gears uses SQLite to store information, and you use SQL from your JavaScript to CRUD (Create, Read, Update, Delete) your data. I wonder how would would store data securely?

If you like, you can explore the databases that are created using SQLite Database Browser. This starts to explain why SQLite was a 2005 Google Open Source Award Winner. ;)

The local storage shows up when running Internet Explorer on Windows under:

C:\Users\Scott\AppData\LocalLow\
Google\Google Gears for Internet Explorer\
www.yourdomain.com\http_80

Within Firefox, the local storage databases go in:

...\Application Data\Mozilla\Firefox\Profiles\
<profile>\Google Gears for Firefox

So it seems I can't go to a Gears-enabled site in IE and later in Firefox and share data. Each browser gets it's own data storage. That means num of browsers * num of gears enabled uris = num of SQLite databases. For folks who run more than one browser, this makes the whole local storage thing a tricky issue, but I can understand why they'd segment databases by browser. I disagree, but I see their point of view.

Gears also includes a thread pool "tiny process pool" like construct that lets you perform CPU-intensive things without triggering the "Stop unresponsive script" dialog box, but you can't touch the DOM. Again, very cool and very intelligent tradeoffs.

Things are looking up, methinks. It'd be nice if Gears-like (Gearsesque?) functionality could get built into next-gen browsers the way that XmlHttpRequest did. Seems like only yesterday I was deep in the middle of the Great Cookie Scare of 1995, explaining to client what Cookies were...NO, they can't write out a megabyte sized cookie, no cookies aren't programs...glad that's over. If we've going to build some rich stuff, let's stop with the Flash Shared Objects and IsolatedStorage already and get the browser to solve this problem. Kudos for Google and let's pray there's no offline ads...

Technorati Tags: , , , , ,

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb
Thursday, 31 May 2007 06:09:43 UTC
When you combine this with Silverlight and .NET within the browser, the possibilities for the types of applications you'll be able to write are nearly endless.

Exciting times ahead...
Sam
Thursday, 31 May 2007 06:28:49 UTC
Wonder how long it will be before Microsoft has a similar closed product that they will try to get everyone to install.
Ben
Thursday, 31 May 2007 07:43:58 UTC
This is Google. Why wouldn't there be ads?
Thursday, 31 May 2007 09:57:13 UTC
Ben: Microsoft have allready suggested that they will support offline storage in Silverlight. They have the security model in place, they have isolated storage, and they are soon shipping Sql Compact Edition (their answer to Sqlite).

So yes, they will support offline scenarios, and no, It's not to rip-off Gears...

But Gears is _really_ interesting. Totally agree with you Sam, the possibilities are endless. The only problem is that Silverlight supports Mac, and Win... Gears supports Win and Linux (no Mac yet). So the smallest common ground is Windows :P

But once Google get Mac support, and the Mono gys get Silverlight on Linux, you can really make some compelling stuff!
Thursday, 31 May 2007 09:58:23 UTC
My bad, it works on the Mac! :)
Thursday, 31 May 2007 13:15:04 UTC
Its definitely sounds like Google and I believe Microsoft is a few steps behind.
Thursday, 31 May 2007 13:21:27 UTC
I downloaded the GoogleGearsSetup.exe but gave me an error.

I have xp. I know Google doesn't like MS but come on now. I can even test their stuff.
wil
Thursday, 31 May 2007 13:39:15 UTC
Flash Shared Objects == Isolated Storage == Google Gears local database.

They're all non-native(/standard) browser plugins.

Anyone know what's to stop me sitting in a loop (in the "thread pool" natch) inserting row after row after row into your local database?

Anyone fancy hosting a database on wordpress.com? We could all share the same database!

Thursday, 31 May 2007 15:36:12 UTC
I feel bad for adobe. now they are competing with microsoft AND google.
Darren Kopp
Thursday, 31 May 2007 15:43:27 UTC
re:Safari

Interesting because last I looked they were promising Safari support but it wasn't ready yet.

Don't forget JavaDB
Thursday, 31 May 2007 16:22:51 UTC
Cookies 2.0
Thursday, 31 May 2007 17:02:44 UTC
Yes, Google Gears should work fine with Silverlight, just as it does with Flash Player. But Microsoft is working on its own database access layer for Silverlight, we're told. Will Microsoft do the right thing and support Google Gears in IE and Silverlight, or will their classic NIH force them to fork a parallel path? I suspect the latter, and its a shame.

Meanwhile, Apollo beta includes Google Gears. I'll bet you that Apollo will do as much to drive the technology to ubiquity as any single browser implementation (Firefox, Opera, etc.).
Thursday, 31 May 2007 17:15:14 UTC
It'd be nice if Gears-like (Gearsesque?) functionality could get built into next-gen browsers the way that XmlHttpRequest did


Hear, hear! Although, you know what we'd get then... At least two (only two, if we're lucky) different implementations.

I've been getting into Javascript lately, and becoming increasingly frustrated that this very cool little language is plagued by so many variations between browsers. (Well, that and the "OO tax".)

Anyone know what's to stop me sitting in a loop (in the "thread pool" natch) inserting row after row after row into your local database?

That does sound like a danger. In my understanding, a savvy user could use the SQLite Database Browser to get rid of a garbage database.... But the question I suppose is whether/how they could be made aware that this had occurred at all.
Waterbreath
Thursday, 31 May 2007 18:16:35 UTC
Offline apps?

We've been doing this for years with IE and plain cache techniques. And if you create an HTA for IE, even better... you have full access to local file system, operating system calls, etc.

What is clear from all the brouhaha over Silverlight, Flash, Gears, etc, is that developers really want to create full applications with the ease of DHTML and Javascript.

See other attempts such as Dojo storage: http://dojotoolkit.org/offline

Web browsers and standards need to catch up to this, and yes provide standardized methods of storage, updates, etc.

Kevin
Thursday, 31 May 2007 19:46:26 UTC
Sounds like the Dojo Offline thing to me...
Thursday, 31 May 2007 19:47:24 UTC
upp - sorry : http://dojotoolkit.org/offline
Andreas
Thursday, 31 May 2007 21:05:53 UTC
Web browsers and standards need to catch up to this, and yes provide standardized methods of storage, updates, etc.


Why? I'm sorry to sound MS-centric, but Silverlight provides this today (and with a much better programming model IMHO). .NET applications provide us with even more richness. Why does everything need to be in a web browser?
Thursday, 31 May 2007 21:24:54 UTC
The main concept of Google gears is the local cache. But then the application has to be pure Javascript to work offline. Most of AJAX applications have a backend code Javascript connects to. How can that be made offline? I have a few more questions

Vijay
Dekoh
Thursday, 31 May 2007 23:30:47 UTC
And it's nice that the application (data and pages) can be cached locally, but what happens if the initial page drops out of the browser's cache? Your application is no longer available offline, right? There's nothing to bootstrap the whole experience...
Thursday, 31 May 2007 23:53:21 UTC
Cookies 2.0?

Have you even looked at SQLite? You can stuff all sorts of things in the database and get it back out via SQL.

You can build a synchronizing n-tier web app on the desktop. If the thought of that doesn't make you drool, nothing will.
Carlos
Friday, 01 June 2007 06:24:20 UTC
Why do you like the Gears approach over Isolated Storage? Because it fits more with the browser model?
Friday, 01 June 2007 15:05:46 UTC
There's one piece of the puzzle that you didn't talk about: Google Apps.

Google Apps can already automatically download applications as they are updated. All google needs to do is add these html "apps" to the list of apps available.


Eduardo Scoz
Friday, 01 June 2007 16:11:38 UTC
Lets not forget why the browser-based applications are important -- they represents the free, ubiquitous framework for accomplishing distributed work.

Hence, two things are necessary to lead to widespread adoption of browser plugins:
1) Ubiquitous client installation-base or fast, well publicized, zero-permission installs
2) Free (as in beer, with a splash of speech) application authoring

XMLHttpRequest passed both tests, by virtue of being integrated into the browser. Flash passed point 1, but failed at point 2, hence its not the defacto solution. Gears and Silverlight are iffy on point 1, so unless they're installable without administrative permissions (or easy pushed via SMS?!) their widespread within enterprise will likely be piecemeal.
Saturday, 02 June 2007 05:38:17 UTC

"But once Google get Mac support, and the Mono gys get Silverlight on Linux, ..."


Apparently you don't realize that Miguel/Mono is becoming the most hated sellout of the entire software industry.

Stephane Rodriguez
Monday, 04 June 2007 16:00:29 UTC
Spell check won't help you with "seams". I only mention it because of your recent focus on blog spelling being so key.
Robert
Monday, 25 June 2007 14:07:26 UTC
Hey Scott,

Check out the little google gears db query tool I implemented.

I'm finding it useful in developing client side db schemas for other gears enabled features I'm working on.

Cheers,

Joe Audette

ps, enjoying your podcasts
Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.