| It's been 4 or 5 months since I switched from Titanium to writing native Objective C myself, so things may have changed since then (but I don't think they have). It's a misnomer to say that Titanium "compiles" Javascript to Objective C. Titanium lets you write Javascript that executes using JavascriptCore (a Javascript processor that is part of iOS) on iOS, and I believe V8 on Android, but I could be wrong on that. Then, they have bindings in Objective C (and Java). So when you call in Javascript Titanium.window.create();, the relevant Objective C is executed by the bridge. This is all fine and dandy until you start doing something more complicated than displaying a few windows. For example, our app needed to have some complicated TableViews with highly customized rows that needed to be re-generated on each draw. Executing the logic for that in Javascript has a huge penalty hit. So while I would recommend Titanium over PhoneGap any day, it is not true that it is a "compiled to Objective C" sort of thing (again, at least it wasn't 4 months ago, and I was using at that time 1.80 which was the super-bleeding-edge-dev build, because I had a ton of issues with random crashes in the 1.7x series due to the Titanium Database module not being completely thread-safe at the time). Sorry to hijack. EDIT: Just to confirm, 1.81 is the current "stable" release, so what I was using 4 or 5 months ago is what is the standard now. So it does not compile Javascript to Obj. C. Also, for an example of the random crashes we were seeing, see: http://www.juliusbuss.de/web/youatnotes/blog-jb.nsf/dx/quick... A lot has been fixed in the 1.8x series, but at the end of the day you're still depending on someone else's middleware to behave and not crash your app for no reason. In case anyone decides to go down the learning Objective C route, learning with the excellent "Programming iOS 4" book took me about 1 month from the first page I read to having the whole app re-written, so it's really not too terrible. You don't have to do any of the memory management stuff anymore with iOS 5 and ARC, either. |
The patterns and frameworks I use in single-page javascript apps carried over well to developing with Titanium, including tools such as Backbone and CommonJS. Titanium supports CommonJS directly now but it wasn't available when I started so I used Stitch to combine the code into a single javascript file and have been happy with the result. One bonus of using this approach is that I've been able to share a large portion of the code with the mobile web version of the app currently in development (using Backbone and jQuery Mobile).
While we ran into some problems that were difficult to track down, the code for Titanium is on GitHub and is easy to fork if you need to. For example, one thing that's prevented me from posting a link to this app previously is that the Android version (also built with Titanium) is experiencing frequent crashes on certain devices. After several (ok, 20+) hours of debugging I discovered that the problem was in the 'click' event handler on table rows -- the handler was passing the whole table row object in the event handler and was causing occasional crashes due to the size of that object. I didn't need that data to be passed in the events so I just commented out that portion of Titanium code and everything's great now (we're releasing an update shortly). Sure, it was a brutal bug to find, but the source was available and not too difficult to follow.
The app also includes custom modules written in Objective C for iOS and Java for Android, but only for very specific functionality that wasn't already included in Titanium -- 99% of what we needed was already available.
If there's any interest I'm thinking of extracting my pattern into a basic application that I can share with others and perhaps build a bit of a framework around it. Here's a gist as an example of code used in the app: https://gist.github.com/1832639
Edit: accidentally used a private gist.