Recently I was given some time (1 week) at my work to explore Appcelerator Titanium. Appcelerator Titanium is a platform for building mobile applications, using pretty exclusively JavaScript. Unlike PhoneGap, it’s not a web app inside a native app, but rather uses very extensive APIs to build a native app for iOS and Android. There wasn’t much of a point to my exploration, except we were curious about the technology and thought it would be interesting to see what it could do.

Before I get to my opinions and conclusions about Appcelerator, here’s where I’m coming from. I am primarily a web developer and am very comfortable and enjoy writing asynchronous, event driven JavaScript. In my computer science days in undergrad I wrote a lot of C/C++ and Java code, but that’s been 6 years now. I’ve written a couple of iPhone apps in Objective C and that went fine, but I can’t say I loved Objective C. I think I prefer C++.

One last disclaimer is that I only spent one week on this and did not see it off to completion. There are a lot of details involved in completing an app that I didn’t get to. So really this is just a first impression. Maybe I’ll write another post after I finish an app in Accelerorator and let you know how that goes. I knew I wouldn’t finish the app in a week, so I tried to go deep and get some harder parts working well rather than getting 80% done and looking almost done, but knowing that the parts left to do would be tricky, maybe not even possible. I wanted to see what limitations I could find using Appcelerator Titanium.

I really enjoyed working with Appcelerator for mobile development. Mostly because, personally, I feel like JavaScript is a very appropriate language for this type of development. Really for two reasons. First it’s an incredibly expressive language, I mean JSON come from JavaScript Objects which is one of the most commonly used ways to express data. The second reason I think JavaScript works well for mobile app development is because it does event driven programming very well. Callback functions can get pretty hairy, but there are some pretty decent ways to overcome that.

Setting up the GUI worked pretty well in Appcelerator. It consisted of describing different types of display elements using JavaScript objects. I’ll demo a little bit of code from the app. It’s not too important to understand what it’s doing, what I’m trying to point out is how Titanium uses JavaScript objects to create elements on the screen.

var versePicker = Ti.UI.createView({
  width: 278,
  height: 614,
  top: 60,
  left: 50,
  visible: false,
});

var versePickerWheels = Ti.UI.createView({
  backgroundImage: "images/bg_mobile_flat_blue_2col.png",
  top: 71,
  left: 19,
  height: 480,
  width: 245
});

var verseSearch = Titanium.UI.createSearchBar({
  height: 44,
  width: 245,
  top: 29,
  left: 19
});

var searchButton = Ti.UI.createLabel({
    top: 560,
    width: 245,
    height: 29,
    left: 19,
    backgroundImage: "images/blue_btn.png",
    text: "Begin Reading",
    textAlign: 'center',
    color: "#fff",
    font: {
      fontWeight: "bold",
      fontSize: 16
    },
    shadowColor: "#aaa",
    shadowOffset: {
      x: -.5,
      y: -.5
    },
    backgroundPaddingBottom: 2
  });

That’s some of the code that renders this:

Verse Picker

The other big part in building an app is handling events. Everything from the app initially opening the app to clicking on buttons to things happening in the background are events and Appcelerator and JavaScript worked very well for this too. JavaScript callback functions handled this very well.

searchButton.addEventListener("click", function(e) {
  var chapter, osis;
  osis = BG.bibleInfo.data[booksView.selected].osis;
  chapter = chaptersView.selected + 1;
  versePicker.hide();
  BG.bibleView.updatePassage(osis, chapter, null, function() {});
});

In my one week experiment I tried to find some limitations and was not able to find any for what I was doing. I was able to get some pretty slick interactions built just the way I wanted. I think this was because of the extensive APIs allowed me to pretty much anything that I could have done just building it natively. I wasn’t doing game development or anything too fancy. But I felt didn’t feel any limitations with anything I would want to do.

I developed exclusively for the iPad, it would be a lot more work to build for the iPhone or Android. I’ve read plenty of horror stories about using Titanium Appcelerator but for the most part it sounded like other people frequently use it wrong. It’s not a magical framework that will organize your code for you and can easily export your app to multiple platforms. You will have to pretty much do all of that yourself. There are some best practices and I noticed some libraries built to help out with code organization. It would be a lot of work getting a single app working for multiple platforms, something I didn’t try, but could see that you’d probably either have to have a lot of conditionals or fork your code. But I have to think a lot of the code would be reusable and it would be nice to reuse some of your code, or at least languages and technologies when developing for multiple platforms.

Overall, I thought it was a very positive experience and I’d like to do a real project in it. Either personally or professionally and see it out to completion. Maybe I’ll post about Appcelerator again some day.



Published

12 February 2012

Tags

comments powered by Disqus