Rich Internet apps that double as desktop apps

Adobe AIR, Curl Nitro, Google Gears, and Microsoft Silverlight are among the cross-platform RIA technologies that can double as desktop app technologies

Finding a single development environment for all purposes has so far proven an unattainable goal. But with the advent of rich Internet applications (RIA), development nirvana gets a bit closer.

RIAs are enhanced Web applications that have additional functionality on the client, which makes them more responsive to the user than standard HTML pages -- and in some cases as responsive as desktop applications. RIA technologies include AJAX, which is a combination of JavaScript, dynamic HTML and an asynchronous server request interface; Flash, a widely available plug-in technology from Adobe often used by designers; Flex, a variation on Flash more suited to programmers; Silverlight, a relatively new plug-in technology from Microsoft that includes a subset of the .Net Framework; and Curl, an object-oriented language with embedded HTML markup.

[ For more on info on rich Internet application platforms, check out "Not your father's Web: The year in RIAs" | And keep up with app dev issues and trends with InfoWorld's Fatal Exception and Strategic Developer blogs. ]

In the past year or so, a number of cross-platform RIA technologies have been released that can double as desktop application technologies. I'll discuss four technologies that accomplish this trick: Adobe AIR, Curl Nitro, Google Gears, and Microsoft Silverlight. I installed them all, explored them, and used them for several months in the course of my work.

Adobe AIR
Adobe AIR is the cross-platform desktop extension to Adobe Flash and Flex. It supports programming in JavaScript with HTML markup in an AJAX model, as well as Flash and Flex programming in ActionScript, a superset of JavaScript. (There is a learning curve if you want to use the extended features of ActionScript. It's supposed to be compatible with most existing JavaScript apps, but your mileage may vary.) The standard Adobe tools for Flash and Flex -- Adobe Flash CS4 Professional, Adobe Flex Builder 3, and the Flex 3 SDK -- can be used for AIR development as long as you update to the current versions or download and install the AIR update for old versions. AIR development is also supported by Aptana Studio.

[ Check out the InfoWorld Test Center review: Adobe AIR soars to loftier heights. ]

AIR adds a number of desktop-specific classes and components to Adobe's base Flash and Flex classes. AIR 1.5 applications can update themselves, interact with the system clipboard, use the file system, use native windows and menus, use a local SQL database, and store encrypted data. AIR also supplies a number of capabilities to the desktop environment for which Flash and Flex applications normally rely on the browser -- for example, HTML rendering, HTTP handling, and network detection.

Publicly available Adobe AIR applications at the AIR Showcase range from simple desktop widgets to full-blown applications. AIR is supported for development and runtime on Windows, Mac OS X, and Linux.

AIR is most useful in the hands of experienced Flash, Flex, and AJAX designers and developers. When I talk to them at conferences or discuss it with them online, these people generally report that AIR development is an easy increment from what they already know, and they often produce gorgeous applications with few downsides in a relatively short time. The most serious problem with AIR applications is that the interpreted ActionScript and JavaScript languages are slow compared to native code, which means that CPU-intensive applications are not good candidates for implementation in AIR.

I am more of a Flex and AJAX developer than a Flash designer. I found the AIR extensions to Flex fairly straightforward to learn and use from Flex Builder, although I would have been happier if the AIR documentation were included in the Flex Builder help file instead of only being available online.

AIR runtime, AIR SDK, Flex 3 SDK, and Aptana Studio are free. Pricing for Aptana Studio Pro is $199, $699 for Adobe Flash CS4 Professional, $249 for Adobe Flex Builder 3 Standard, $699 for Adobe Flex Builder 3 Professional, and $399 for Adobe Dreamweaver CS4.

Curl Nitro
Nitro is the cross-platform desktop extension to Curl. Currently in its second beta-test release, Nitro adds an applet installer, desktop controls and a client-side SQLite database to Curl's excellent RIA capabilities. Nitro applications take advantage of Curl's high-performance, skin-able user interface and built-in security sandbox. Even without Nitro, detached Curl applets can be used for desktop applications: The Curl IDE and help system are good examples of that.

Curl may not be as familiar to you as the competing products from Adobe (AIR), Google (Gears), and Microsoft (Silverlight), but you shouldn't let that deter you from trying it. It has CPU-bound runtime performance roughly 10 times that of Adobe AIR, according to a test of JPEG encoding conducted by Curl in May. (The test was pooh-poohed as "irrelevant" by Adobe, but not refuted.)

In addition to high-computing speed, Curl has (according to my own speed tests) very high-performance graphics, at least on the Windows platform when using DirectX. It also has demonstrably strong security. (Curl has criticized the Adobe AIR security model as having a huge hole in its signing certificate scheme.)

The Curl language may be new to you, but it isn't hard to learn. In addition to providing copious documentation, Curl supplies many excellent samples with source code, a number of interactive tutorials on application-specific topics called Curl Cues, a Curl IDE Made Easy interactive training program and online courses on the Curl language, the Visual Layout Editor, and the Curl application development process.

I was initially baffled when I looked for the Nitro extensions in the current Curl IDE documentation. Then I looked at the source code for the three Nitro samples supplied on the Curl Web site, and that made it clear where to find the Nitro functions in the Curl libraries. One of the Nitro samples did not work for me, however, because of a problem with the Facebook API. The other two samples worked very well.

The Curl RTE (runtime environment) runs on Windows, Mac OS X, and four versions of Linux. The Curl IDE runs on Windows and Linux. The Curl development plug-ins for Eclipse work with Eclipse 3.3 and 3.4 on Windows and Linux platforms.

The base Curl IDE and runtime that include Nitro are free, as are deployment licenses for publicly available, free Web sites that use the base capabilities. A Curl Pro/Deployment license starts at $12,000; Curl has pricing models designed for enterprise, Internet, software-as-a-service and reseller business models.

Google Gears
Google Gears is a free open source project that adds desktop capabilities to the Internet Explorer, Firefox, Safari, and Chrome browsers on the Windows, Windows Mobile, Mac OS X, Linux, and Android operating systems. (Chrome has Gears built in and does not need a separate installation.) Currently at Beta Version 0.5 (but ready for prime time now), Gears lets Web applications interact naturally with your desktop; cache and store application resources and blobs (binary large objects) locally; store data locally in a fully searchable SQLite database; run JavaScript in the background to improve performance; and perform geolocation both by IP address and by Wi-Fi antenna data.

Basically, Google Gears is a way to take Web applications offline in a browser. Curl Nitro and Adobe AIR can go one step further and dispense with the browser.

Google Gears exposes a JavaScript API to supported browsers. Google hosts the Gears runtime engine, which users must install before running any Gears applications. Developers need to copy gears_init.js into their application directories and call it in order to initialize the Gears factory and APIs; this script will offer to launch the Gears installer if it cannot initialize successfully.

The online Gears developer documentation discusses Version 0.5, released a month ago. It includes nine samples that illustrate the use of the APIs. You can download the source to all of these samples, plus some articles, a couple of tools, and an Apache mod implementing the resumable HTTP request proposal. One of the articles is a tutorial on taking Web applications offline with Gears, written by Omar Kilani of Remember the Milk. Kilani and his team implemented offline functionality for their application in "four caffeine-fueled days."

I found the sample code very easy to understand. The Gears API is very straightforward, and like other Google APIs, won't present a problem to experienced JavaScript developers. The samples all worked well for me.

Google Gears is free. Adding Gears functionality to a Web page is a simple exercise in JavaScript programming, which can be accomplished using any HTML or text editor. The effort of taking a Web application fully offline with Gears is commensurate with the complexity of the application. Note that using a local database to synchronize large amounts of data can introduce performance issues; this is the reason for the asynchronous JavaScript WorkerPool API.

Microsoft Silverlight
Microsoft Silverlight is a cross-platform RIA browser plug-in. Silverlight 2 includes a subset of the .Net Framework and of the Windows Presentation Foundation (WPF) with its XAML markup language, and supports all the .Net languages in addition to JavaScript.

[ Check out the InfoWorld Test Center review: Silverlight, for real this time. ]

Silverlight 2 supports local data caching and isolated local storage, which is one reason to consider it for use as a desktop RIA, although like Google Gears it runs inside a browser. There's also another scenario to consider: With care, you can write a Silverlight Web application that can also be recompiled to be distributed as a WPF desktop application, and the WPF application would stand alone but be able to connect to the Internet as needed. Note that it's much easier to write a Silverlight application and recompile it for WPF than it is to take a WPF application and rewrite the parts that aren't supported by Silverlight.

Silverlight 2 and WPF both have excellent performance if you program them with .Net languages such as C#. If you instead program Silverlight using the JavaScript interpreter in a Web browser, the CPU-bound performance will drop significantly.

Silverlight 2 runs as a runtime on Windows XP, Windows Vista, and Mac OS X on Intel-based Macs. Current versions of IE, Firefox, and Safari are officially supported, with "others pending customer feedback"; I have also used Silverlight 2 successfully with current versions of Google Chrome and Opera. The Microsoft development and design tools require Windows; an Eclipse plug-in for Silverlight currently requires Windows but will eventually support other operating systems. The Linux implementation of Silverlight 2 is called Moonlight 2 and is currently in an alpha state.

Silverlight has copious documentation and very good tool support. Developers typically work on Silverlight applications using Visual Studio 2008 on Windows; designers typically work on the same project using Expression Blend 2, also on Windows. Both of these tools are very good for their target audiences, but not for their secondary audiences. That is, Visual Studio 2008 is great for coding and XAML text editing and can preview XAML pages, but can't do visual XAML page design; Expression Blend 2 is great for visual XAML page design but doesn't support coding. The future Visual Studio 2010 product, now in preview, will combine both sets of capabilities.

I am not especially impressed with the Silverlight 2 local data caching and isolated storage facilities, which are not safe from access by unmanaged code and lack an actual database. (For many occasionally connected applications, you want a local database not only to cache information read from the remote database, but also to store updates to be sent to the remote database when the connection is restored. It's easier, more efficient, more secure, and more reliable to do this with a local database than with a simple caching facility.)

On the other hand, I'm very enthusiastic about Silverlight 2 as an RIA. If I wanted to build a Silverlight Web application and needed a desktop version as well, I would lean toward separately compiling the application for WPF. I would expect to have more than 90 percent of the code shared between the two projects if planned properly.

The Silverlight plug-ins, Silverlight SDK, .Net Framework, and Visual Studio Express Editions are free; Visual Studio 2008 Standard Edition is $299 ($199 upgrade); Professional Edition is $799 ($549 upgrade). Subscriptions range from $1,199 for Visual Studio Professional with MSDN Professional up to $10,939 for Visual Studio Team System 2008 Team Suite with MSDN Premium. Expression Blend 2 is $499 ($99 upgrade).

The first question to ask when picking a desktop RIA is how the application will be used, both as a Web application and a desktop application. Then list the features you need. Are those features present in the RIAs you are considering? Are there ways to add missing features? Are you looking to enable fully or occasionally connected scenarios?

Once you've got your questions ready, you can figure out which RIA is best for your needs.

Would it be better if you had separate desktop and Web applications that shared a common code base? If so, consider a combination of WPF and Silverlight.

Will your application have CPU-bound portions? If so, consider Silverlight and Curl Nitro.

Does your application need to run locally without a browser? If so, consider AIR and Curl Nitro.

Do your developers already know WPF and the .Net Framework? If so, consider Silverlight. Do they already know Flash and Flex? If so, consider AIR.

Do you already have an AJAX Web application? If so, consider AIR and Gears.

Finally, ask yourself if you really need a desktop RIA at all. Sometimes building a second interface for an application is a relatively small effort, if most of the work is being done by a common back end or if most of the code is common to both versions of the application. In the larger picture, sometimes the advantages to users of having separate but optimized desktop and Web user interfaces may outweigh the costs and time involved.

Martin Heller is a software developer and consultant, as well as an InfoWorld contributing editor. He writes the Strategic Developer blog. Computerworld is an InfoWorld affiliate.

This story, "Rich Internet apps that double as desktop apps" was originally published by Computerworld.

Copyright © 2009 IDG Communications, Inc.