Snook.ca

Creating Desktop Applications with Titanium

After my adventures in developing with Adobe AIR, I've been keeping an eye on the state of cross-platform desktop application frameworks. In the past year or so, I know of JavaFX and Titanium that have also hit the market. Not being a fan of Java, I stayed clear of JavaFX. Titanium, on the other hand, with its similarities to Adobe AIR, has been a more compelling option.

Titanium is an open source platform for building desktop applications using HTML, CSS and JavaScript. Applications can run on Windows, OSX and Linux and have access to local resources, the TCP stack, integrated SQlite support along with the ability to create standard and chromeless windows.

Webkit conquers all

The most compelling part for me is the use of Webkit as the primary engine. Theoretically speaking, an application could be built using a similar codebase and deployed for the web or as a desktop application via Titanium or Adobe AIR, which also uses Webkit.

Where Titanium excels over AIR is in its support of more current Webkit features. Adobe's version, in many ways, is actually quite limiting with lack of support for the little things that can really provide the polish for a desktop application: like Cmd/Ctrl-Z support for undo. Keyboard support in HTML-based AIR apps was frustratingly poor in earlier versions.

It has support for CSS animations and transformations. The examples from the Webkit blog work just fine.

It even has support for custom scrollbars (although that may only be recent builds of and not PR3, specifically). Adobe AIR has rather unattractive scrollbars with no way to change it except to use JavaScript widgets. Here's the kicker, though: Titanium automatically uses the OS style for things like scrollbars, which, in my case, actually made custom scrollbars somewhat moot.

Chrome

The OS windows chrome and transparency support in Titanium also excels over Adobe AIR by allowing native controls — like close, minimize and maximize — and semi-opaque documents at the same time. With AIR, you have to make an either/or choice.

Type Rendering

Type rendering, especially on the Mac, is much better as it uses the OS for control. Likewise, it supports the OSX's built-in spellchecker.

Cursors

Adobe AIR has poor support or CSS cursors, missing all of the resize cursors. If you have a UI that needs resizable panes you'll have to be creative. Titanium on the other hand, has full support for CSS cursors including the ability to declare a custom cursor.

OSX features

Now that I'm on OSX, I understand some of the frustrations that users had with Snitter. A good example of that was lack of menubar support. A twitter application is actually well suited to find its way into the menubar and Titanium allows you to do that, where Adobe AIR can't.

Titanium even comes with Growl support, out of the box.

Not all roses

Despite all the stuff going for it, Titanium isn't all roses. It's still in development, which means the application can and will crash. During testing, I've locked up my simple app and crashed it a few times.

Debugging

Debugging is also cumbersome. The Webkit Inspector comes built-in but the debugger isn't enabled by default. Opening the inspector also opens as a popup pane of the current document instead of in its own window. They'd do well to build a simple debugger shell that could be included with an application during development and that would launch in its own window by default.

Documentation

Documentation is also lacking, forcing you to look at the example applications, or hanging out on the IRC channel for more details. Thankfully, the folks on the IRC channel are super helpful and very friendly. They were able to answer any of the questions I had quickly.

Small Community

It's hard to argue this as a good point or a bad point but the fact is, the community of developers working on Titanium is quite small. As a result, there simply isn't many resources available to try and troubleshoot these types of issues.

On that note, the Adobe AIR community for JavaScript developers is also somewhat small. At Adobe MAX last year, there were very few AIR/JavaScript sessions and certainly none that went into any detail on the platform.

Advantage, AIR

There are still some solid advantages to using Adobe AIR over Titanium. Adobe AIR is a stable platform with a larger developer community as a whole, especially if you're a Flex developer. AIR has plenty of documentation and plenty of people building applications on the platform. There's better "web site to application" integration (although few really take advantage of this).

AIR also runs on top of the Flash runtime, allowing pixel bending on the entire canvas, including the Webkit control.

Deployment

Deployment is quite interesting in that it creates native installers for each platform, instead of a packaged file like Adobe AIR. It also handles packaging via a cloud deployment system, which means you have to be connected to create your applications.

There's also currently no command line interface, which forces you to keep the developer application open to continuously relaunch your application during testing.

One of the nice things about deployment is the ability to choose what components of the runtime actually get bundled with the app. This should help ensure that your app doesn't suffer when the runtime gets a new version. (Snitter ran into this and is broken in AIR1.5.)

Next Version

The next version of Titanium is expected within a few weeks and it'll be interesting to see how things have progressed since the last release. If you're particularly adventurous, you can also check out the Github repo.

Titanium looks to have great potential but needs to stay focused on getting a stable 1.0 release out the door along with quality build tools and documentation. If they can do this, they have a good chance at creating a successful platform.

Conversation

Nice post. I have been watching Titanium for awhile. I haven't developed anything in it yet, but with the new version coming out, maybe it's time. I wonder how many users have Titanium installed. Any ideas?

@Scott: The user base is, if I had to guess, only a couple hundred people with only a few very active developers. Within the Developer tool, you can see a list of public apps and it's currently quite small with the largest app only having a few hundred downloads.

I have something in the works that'll hopefully make developing an app using either Titanium or AIR even easier but I'll spill the beans if and when things get close enough to release.

I've played with Adobe AIR a bit, but haven't looked at Titanium until now. It does look quite promising--the menubar support would be a huge plus, and little things like OS X scrollbars can really make a difference.

Thanks so much for your very fair and objective review of Titanium. We're a ways off from getting to a high quality production version of Titanium ... but we're working hard at it and have a very committed community. The beauty is that anyone can help participate in any number of ways.

Adobe AIR is a great product - something we have a lot to look up to and a very strong competitor.

If anyone runs into issues, please please please report them so we can investigate and fix them. http://jira.appcelerator.org

Also, we welcome anyone to join us either at http://community.appcelerator.org or on IRC at #titanium_app at irc.freenode.net

The only problem I have with these "frameworks" is that the memory use is ridiculous compared to a similar app in a dedicated language. Even little "widget" apps often take 50+ MB of memory to run, and like earlier versions of Snitter, have some odd memory leaks.

@Chris: memory usage and memory leaks in particular are a huge issue for applications built on top of browser technology. The 'problem' is that you're loading an instance of a browser to get the functionality you want, there's no other way to look at it. That comes with a hefty price tag.

As a developer, we also have poor tools to properly trace things like memory leaks. Only be running the application under more extreme situations does it tend to get resolved. I had to do a fair bit of testing with Snitter to track down where the memory leaks were. (I believe the as3notification library was the main one left, since creating new windows and destroying them improperly would leak memory quite rapidly.)

I looked at Titanium a bit as well. The "open source" really caught my eye. Then, I noticed that compiling is done in the cloud. Just as you mentioned "It also handles packaging via a cloud deployment system, which means you have to be connected to create your applications."

So, what happens if Appcelerator gives up on Titanium? Will they continue to maintain the packaging service? Would they make the packaging system available for someone else to host? Titanium is open source, but might Appcelerator start charging for packaging? If you developed an app for a customer, would you be unable to update it in the future if Appcelerator the packaging system down?

I'd like these types of questions answered before putting effort into this tool.