Titanium 1.0 - Native Web Apps Have Arrived

DZone 's Guide to

Titanium 1.0 - Native Web Apps Have Arrived

· Web Dev Zone ·
Free Resource
Today is a major milestone in the evolution of the web as an open development platform.  Appcelerator's newly unveiled Titanium 1.0 framework lets web developers build native applications for the iPhone and Android phones using nothing but web languages.  This means that Titanium applications can leverage any functionality of the iPhone or Android operating systems without going through a browser or WebView.  Over 27,000 developers have already started using Titanium with an average of 5,000 new users per month.  DZone talked to Scott Schwarzhoff, who was once an independent developer himself and is now Appcelerator's VP of marketing.

Your Choices as a Mobile Developer
Mobile developers have traditionally had to decide whether they want to build native apps or web apps for mobile devices.  Native apps have most of the advantages in performance and seamless usability.  The user experience on a web app can't leverage the relationship between the user and the device in the same way that native apps can.   If mobile developers choose to build native apps, the investment is significant.  

Forrester Research finds that most applications take at least three months to develop working full-time.  The cost is between $20k - $150 for each application, and Schwarzhoff says that's a tame estimate.  There's also the blaring fact that you are locked into one platform with its own particular SDK.  Developing for multiple platforms means you have to learn multiple languages.  With the mobile market moving so fast, who knows what the next major platform will be in 5-10 years?

As an example, Gartner expects the Android platform to surpass Blackberry and the iPhone by 2012.  The advantage of the web app is the intrinsic openness of the development platform.  A web app in the form of JavaScript, CSS, and HTML code can run on any device with a web browser.  The cost is significantly less and you only have to learn one language.  

What Titanium Does
Titanium uses a host of special APIs to blur the line between web apps and native apps.  The Titanium SDK essentially allows web developers to use their skills to call Titanium APIs and build applications that run natively on desktops, mobile devices, notebooks, tablets, and set-top boxes.  The Titanium Mobile toolkit supports native Android, iPhone, and iPad application development, and Titanium Desktop supports PC, Mac, and Linux development.  Titanium also offers other Appcelerator technologies such as cloud services to lower development cost and speed up the app development process.

Here is a model of the Titanium architecture:

The web source files essentially map through Titanium APIs that call native functionalities such as GPS, camera, animations, and accelerometer.  With such a huge array of APIs, applications developed with Titanium can natively leverage just about any feature you can imagine.  Here are some examples:

  • 2D/3D animations
  • Geo-location, compass, and maps
  • Augmented reality features
  • Social app authentication and native client support for email
  • SOAP or REST API calls
  • Audio, video, and image capture and playback
  • Taps into local filesystem and SQL lite databases
  • Accesses photo gallery or address data

Titanium also makes it incredibly easy to call different native functions in your application.  Here are three function call examples:

  • Ti.UI.showcamera(callback) - camera access
  • Ti.UI.createSound() - streaming audio
  • Ti.UI.createMap() - map interface

These calls save a ton of time during mobile app development.  Instead of having to write many lines of code in the native language of the OS every time you want to access streaming audio or maps, Titanium takes care of everything with a simple call.  The iPhone, for example, would require around 2,000 lines of Objective-C code to access streaming audio.

You can also extend Titanium with your own native modules written in Java for Android or Objective-C for the iPhone.  For example, the Titanium developers took the Facebook SDK and compiled it in an application as a module, which is written in Objective-C, and accessed the SDK  much more efficiently through JavaScript.

Titanium 1.0 Release
In Titanium 0.8, WebKit's WebView was used as the core around which things like GPS, UI, Camera, and Data were mapped to the OS.  In Titanium 1.0, developers now have the option of bypassing the JavaScript bridge for Objective-C (iPhone) or Java (Android) with APIs that bind directly to the OS.  This was achieved by stripping the Web View down to just the JavaScript emulator.  Titanium gives you that emulator to use as your core engine.  Schwarzhoff said that the Appcelerator developers "have spent the last three months tripling the size of our API set so that we could just map everything that you do natively to an API."

Using direct API calls in place of the WebView mediation affords a 3-5x boost in performance for Titanium apps.  With web-hybrid model in Titanium 0.8, applications took 10-20 seconds to launch and 1-2 seconds to transition.  In 1.0, Titanium apps launch in 1-2 seconds and transitions are instantaneous.

Schwarzhoff says most of the Titanium applications that Appcelerator built were written in two weeks because of the code trimming features.  Appcelerator also provides a cloud network used for testing, packaging, distribution, and analytics for your applications (similar to what Google analytics does for web pages).  For the Apple App Store, you would have to jump though some hoops to certify, provision, and package your application for the market.  If you use Titanium, it takes care of these steps for you.

Titanium Business Model

Schwarzhoff stresses that both editions of Titanium essentially have the same features.  The Community Edition is free and it is aimed at developers who want to get a feel for the platform and possibly build free apps that gain revenue from advertising.  Appcelerator is currently working on a revenue sharing model for advertisement funded apps.  The free edition also has a 3 second splash screen when a user starts up the app.  There's also a Professional Edition (no splash screen) that is $199 per developer per year.  It includes a direct line of support from Appcelerator along with cloud analytics for your applications and early access to upcoming platform support for BlackBerry and the iPad.

Appcelerator is launching a Developer Center to help Titanium users get started and provide training.  Appcelerator also provides several free and open source applications to help developers get started with Titanium 1.0:

  • KitchenSink is the unit testing for every API that Titanium provides.
  • SnapPost is a basic image viewing app to see how Titanium applications work.

All versions of Titanium are licensed under the Apache License v2.


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}