Wednesday, July 20, 2011

Mobile Apps with Appcelerator and CoffeeScript?

We're developing our first mobile app at work. We've decided to use Appcelerator as the development tool. Three reasons:

  • Native UI;
  • Cross-platform applications - at least, iOS (iPhone/iPad) and Android;
  • Someone has already developed a similar app using Appcelerator, so we're pretty sure Appcelerator will meet our needs.

If you've looked into mobile development tools, you may find Native UI and Cross-platform applications an unlikely combination. Typically, tools for cross-platform mobile development use HTML/CSS/JavaScript within a browser-ish UI component. The browser component gets wrapped in a thin native layer. The result is a self-contained app, but the UI is HTML etc., not native. PhoneGap is an example.

Appcelerator also uses JavaScript, but very differently - nothing to do with webpages or HTML or CSS or the DOM. In Appcelerator, JavaScript is the only programming language, but it includes a library of mobile API's. Adobe does something similar with Acrobat - JavaScript + application-specific libraries/objects.

The native part: when you build your app, Appcelerator bakes in platform-native versions of the API's. So a button becomes an iOS button, or an Android button, or whatever. This is great - instead of developing everything in Objective C for iOS, and then again in Java for Android, you develop once in JavaScript.

So what's the downside? Well, that would be JavaScript. It has a lot of warts. And the solution? CoffeeScript, maybe. CoffeeScript is a JavaScript replacement, a clean language that borrows good ideas from Ruby and Python, among others. And CoffeeScript compiles into readable JavaScript. So you can code in CoffeeScript and produce JavaScript as needed, - for a browser, or Appcelerator, or anywhere else. CoffeeScript is getting lots of traction - it's standard in Rails 3. 

Some people have already made the Appcelerator/CoffeeScript combo work. I'm eager to try it. Since we're new to this mobile stuff, we don't have years of legacy code locking us in. We can try to pick the right tools, and map a path for future development. It's exciting.

No comments:

Post a Comment