January 20, 2009

The cross-platform option: Web apps for smartphones

Tailoring a Web application for iPhone, BlackBerry, and other top devices has many advantages over costly native development, and new techniques and approaches are closing the functionality gap

Fred Grott, a programmer who specializes in smartphone applications, has two models for his business: He can write specialized applications in native code that take advantage of all of the features of a specific smartphone, or he can write a Web application that works in the Web browsers of all of the top devices.

"Guess which one of those business models [needs] $15K in seed capital and [which] one is in the $250,000 range?" he asks. Given the economics, Grott's choice is simple. Take a standard Web application, add a bit of logic that tests the type of Web browser, and then send back slightly customized versions formatted to the screens of smaller handsets.

Developers are attacking the smartphone market in any number of ways, but one of the most overlooked is the customized Web application. The high sales figures from Apple's App Store seem tantalizing, but native code is not always the best solution.

[ Go native with Apple iPhone, Google Android, RIM BlackBerry, Palm, Nokia Symbian, and Windows Mobile. See "A developer's-eye view of smartphone platforms." ]

After experimenting with writing native code for the different smartphone platforms, I took a step backward and played with recoding my Web application. Instead of writing Java, C#, or C++, I fiddled with CSS files to format the information for the screen and then wrote JavaScript to handle the events. The results are quite good. While I can't recommend the solution for sophisticated games that rely heavily on an accelerometer for the user interface, I can say that just about everything else can be handled quite well in JavaScript. There's a reason why Steve Jobs toyed with limiting iPhone developers to this tight sandbox (i.e., Safari applications) at the beginning. It's pretty good.

There are a number of reasons why HTML works well in this environment. It was designed from the very beginning to mark up documents without regard for the size of the display. Although Web designers have always chafed at the lack of control for errant DIVs, the results will often look quite good on the smaller display. Picky designers will still want to come up with custom CSS files and even some custom markups for the smaller screens of the smartphones, but the default is often serviceable.

A second major advantage is the popularity of WebKit, an open source library that renders HTML on the page. The iPhone and Google Android both use WebKit directly, and now Torch Mobile is making a WebKit-based browser for Windows Mobile. Eliminating the incompatibilities among mobile browsers makes it a bit easier to develop cross-platform tools. Android may run Java and the iPhone may be built on Objective C, but the same application can reach both via WebKit.

Some developers lament that semi-standard platforms such as Adobe Flash aren’t well-represented across all of the phones. That may not be as unfortunate as it seems. Many designers love Flash because it lets them lock down text and pictures to hard-coded coordinates, something that may look good on a normal screen but will fail badly on the smaller mobile screen. It's hard to write up Flash that runs well on both large and small screens, so the empty hole may be a blessing.

Close

On Twitter now

Application development

Powered by Twitter

White Paper

D2D Virtual Tape Library Replication Primer

This whitepaper explains the terminology and concepts behind Data Replication technologies and establishes some sizing rules through worked examples. Learn the new paradigm in disaster tolerance—protect data anywhere.

Download now »

White Paper

An Alternative to Virtualization for Datacenter Cost Savings

Server virtualization is a popular option for dealing with mounting datacenter costs. Another equally promising approach is the use of an Application Delivery Controller. Citrix NetScaler provides a low-cost way for organizations to reduce their server count and accrue cost savings from a reduction in space, cooling, power and personnel.

Download now »

White Paper

Why Your Firewall, VPN, and IEEE 802.11i Aren't Enough to Protect Your Network

The emergence of WLANs has created a new breed of security threats to enterprise networks.

Included in HP ProCurve WLAN solutions is security technology that alleviates threats from WLANs through:
* Monitoring wireless activity inside and out of the enterprise
* Classifying WLAN transmissions into harmful and harmless
* Preventing transmissions that pose a security threat to the enterprise network
* Locating participating devices for physical remediation

Download now »

White Paper

Bringing the Edge to the Data Center

Effectively address data protection challenges, implementing solutions that help store and protect business–critical data while cutting costs and improving efficiency and reliability.

Download now »

Sign up to receive InfoWorld Resource Alerts

Subscribe to the Developer World Newsletter

Receive a weekly roundup about the art and science of software development.

©1994-2009 Infoworld, Inc.