Moving targets
By Tim Anderson
Mobile platforms bring both new opportunities and new problems. Tim Anderson finds out what’s involved.
HardCopy Issue: 51 | Found In: Development | Published: 23/02/2011 | Last Revision: 01/03/2011
Mobile development is hot. The combination of ever-more powerful Smartphones and tablets with always-on internet has opened up a new market for personal software, as well as forming an important platform for internal applications.
Mobile development is also fragmented. Multiple platforms are jostling for position: Apple with iOS, Google with Android, RIM with its Blackberry and Tablet OS, Microsoft with several varieties of Windows, HP with Palm WebOS, and others. Competition is good, but does present difficult choices for developers. Which platform or platforms should you target, and are cross-platform development tools good enough to satisfy users?
There is no simple answer. Mobile devices are resource-constrained compared to desktop and notebook PCs. One answer is to build native code applications using C, long favoured for embedded development thanks to its efficiency. Apple advocates exactly this for iPhone and iPad (iOS) development, at one time even including a clause in its developer agreement that stated:
“Applications must be originally written in Objective-C, C, C++, or JavaScript as executed by the iPhone OS WebKit engine, and only code written in C, C++, and Objective-C may compile and directly link against the Documented APIs.”
In September 2010 Apple removed this clause, though it still does not allow runtimes such as Flash or Java onto iOS devices. Nevertheless it is a hint that Apple considers native code written specifically for iOS is optimal, as opposed to cross-platform toolkits. CEO Steve Jobs says this explicitly in his ‘Thoughts on Flash’:
“Flash is a cross platform development tool. It is not Adobe’s goal to help developers write the best iPhone, iPod and iPad apps. It is their goal to help developers write cross-platform apps.”
Microsoft supplies excellent tools for Windows Phone 7 in Visual Studio 2010, but its mobile devices have only a small market share.
While this makes sense from Apple’s perspective, it is not so good for developers facing demands for software on multiple platforms. Small teams face the challenge of learning the SDKs for each platform, and making sure they can code in Objective C for iOS, Java for Android, C# or Visual Basic for Windows Phone 7, and so on.
Using a cross-platform toolkit makes it possible to target multiple platforms with a single code base, reducing the cost of development and making it easier to maintain the application and to keep all editions at the same level. Although there may be compromises, it may not otherwise be viable to support minority platforms.
Not all mobile platforms favour C or C++. Languages like Java for Android and C# for Windows Phone 7 compile to intermediate rather than native code, though they are the officially recommended development platform for those devices. It is possible to develop in C/C++ for Android using the Native Development Kit (NDK), though Google does warn:
“The NDK will not benefit most applications. As a developer, you need to balance its benefits against its drawbacks; notably, using native code does not result in an automatic performance increase, but always increases application complexity.”
The merits of native versus managed code are interesting to debate but the success of Android shows that using managed code is not in itself a barrier to creating excellent mobile apps.
Microsoft’s mobile story is currently fragmented. Windows Phone 7 is its new smartphone platform, and uses Silverlight on XNA, a .NET wrapper for DirectX, as its development platform. Tooling support in Visual Studio 2010 is excellent, ahead of most others in terms of productivity.
However, Windows Phone 7 currently targets consumers, and business users are directed towards the older Windows Mobile despite its declining market share. Another factor is that the full Windows operating system is being ported to the leading low-power mobile CPU, namely ARM, which implies that some future mobile devices will run the next version of Windows, perhaps with a new touch-friendly user interface.
Another option for mobile clients is to stay within the browser. Mobile Web applications have zero deployment and can work well across a variety of devices. The main disadvantage is the lack of access to device features such as the phone and camera, and while offline use is possible using HTML5, this is limited compared to a native app. Another factor is that paid-for apps are easier to market than paid-for Web applications.
Mobile and cloud
Many mobile apps need an Internet component in order to take advantage of live data and to get around the limitations of local storage. This means that integration between a server application and the mobile app is critical. In many cases, Web services using REST and JSON (JavaScript Object Notation) make sense for lightweight mobile apps.
Some vendors offer both server and mobile pieces, which simplifies app development. In particular, Microsoft has ASP.NET and Windows Communication Foundation (WCF) which work nicely with its mobile tools. You can host these on the Windows Azure cloud platform, using SQL Azure for the database, for complete end-to-end integration, or you can host on your own servers. Adobe has LiveCycle Data Services which support Flash-based clients and which run on Java application servers, which is ideal for integrating with existing Java applications.
Stores and programmes
If you are used to the free and easy world of desktop development, the transition to mobile takes some adjustment. Not only is development itself more challenging, but in many cases you have to sign up as a developer for each device family, usually with a fee attached. Further, applications will need to be submitted for approval before they will appear in the appropriate app store for the device, such as Apple’s App Store, Android Market, or Windows Phone marketplace. If you sell an app, a proportion of the price is retained as a fee for the app store services, typically 30 per cent. The price is tax-inclusive so sales tax may further reduce your income.
Corporate developers generally have an easier time. Apple runs an iOS Developer Enterprise Program, costing $299 per year, which lets you distribute in-house apps via iTunes within your organisation. Android deployment is potentially less burdensome, since you can publish applications through any Web server, though mobile operators may restrict this ability on branded devices. RIM has good support for enterprise app deployment on Blackberry devices. Currently Microsoft does not have a solution for internal deployment of Windows Phone 7 applications, though this is possible for the older Windows Mobile platform.
Another factor is whether you can create trial versions of an app, making it easy for users to pay for an upgrade. Currently Windows Phone Marketplace supports this, but Apple’s App Store does not, for example. If this is not available, developers wanting a trial version have to create two separate apps, one free and one paid for. This adds friction and therefore reduces sales.
Cross-platform toolkits
Several cross-platform mobile toolkits are available. Adobe AIR is based on the Flash runtime and enables development in Flash, ActionScript and the Flex layout language. On the desktop AIR runs on Windows, Mac and Linux, but on mobile the only supported platform at the time of writing is Android 2.2 or higher. That said, support for other mobile platforms is planned, and RIM has a Tablet OS SDK for Adobe AIR, targeting the forthcoming PlayBook which is due out in 2011, first in the USA and later worldwide. Adobe also has a Packager for iPhone which lets you build iOS apps from Flash Professional. AIR is supported by Adobe’s excellent Creative Suite design tools as well as Flash Builder, though it can be slow and resource-hungry. Performance will improve as next-generation chips appear with Flash acceleration in the hardware.
Building an app using the C# language, MonoTouch and the MonoDevelop IDE. In this case the app includes an embedded Web browser.
MonoTouch from Novell is an offshoot of the Mono project, an open source implementation of Microsoft’s .NET Framework (although MonoTouch itself is a commercial product). MonoTouch allows development for Apple iOS using C# and the .NET Framework, though your app is compiled to native code for deployment. The IDE is the free MonoDevelop, and although there are versions of MonoDevelop for both Windows and Mac, in this case you need to be working on a Mac with the iPhone SDK installed. MonoDroid is a parallel product for Android, currently in preparation. Although it may enable reuse of C# code, MonoTouch is not altogether a cross-platform toolkit since much of the code will be platform-specific, but it is still a strong option for .NET developers.
Appcelerator Titanium is an open source toolkit that lets you code a mobile app in HTML, CSS and JavaScript, supplemented by Python, Ruby or PHP, and compile to native code for iOS, Android or (coming soon) Blackberry devices. There is also a desktop SDK for Windows, Mac and Linux. The Community edition is free while the Professional edition, which adds product support, training, and analytics, costs $199 per developer per month. Appcelerator recently acquired Aptana whose main product is a JavaScript IDE based on Eclipse, and this will become the primary IDE for Titanium development. Strengths of Appcelerator include native code compilation and the ability to include native modules such as Objective C on iOS or Java on Android. Development tools are weak but should improve following the Aptana acquisition.
Nitobi PhoneGap is another open source framework based on HTML and JavaScript, and targets iOS, Android, Blackberry, Palm and Symbian. MeeGo and Windows Mobile support is in preparation. In essence, PhoneGap uses the local HTML and JavaScript engine to power apps rather than Web pages, supplemented by access to device features such as phone, contacts and location. PhoneGap itself is free, though there are some commercial tools from third parties, and Nitobi offers a range of commercial support services.