I always wanted to develop Mac apps, but as I never had the time to learn Objective-C, I started searching for other available options that used easier to learn programming languages or those ones I already use.
After testing a some of them, like MacRuby, a few months ago I came across an excellent software called Titanium, which enables you to build desktop AND mobile applications using your good old HTML + Javascript.
Truth be told, by then I didn’t quite get how it worked, mostly fault of their messy and not so extensive documentation and my lack of time to magically discover everything. In fact, I installed it just because it was necessary to run bowline.
Two days ago I was browsing my Applications folder and happened to see it was still installed, so I though about giving it a second chance.
And I’m glad I did.
In about 5 hours, I created my first (at least my first useful) Mac app.


One might say that spending 5 hours developing a simple, 2-window app is a hell of a noobie job. Yes, it may be.
But the fact is that I spent 5 hours developing while learning how it worked AND trying to make it look nice. So, 5 hours from scratch to complete.
Damn it, the first time I tried doing a Hello World on Objective-C, I spent 5 minutes building the interface on XCode and at least 2 hours (not that long, I’m just trying to prove my point) looking at the API just to find out how to connect to a database and another while to populate a grid list.
And the best thing is that you can use Ruby, Python and PHP code.
No, I’m sorry. The best thing is that you can package it as a Mac, Windows or Linux application.
It’s almost perfect.
About the app
Whenever I’m learning a new programming language, I like to create a complete app that monitors stock prices (like a price ticker). It stores your favorite stocks and retrieves up-to-date prices.
So, first of all, I need a database to store which stocks I need to monitor, and I need to load a web page or webservice (usually I use Yahoo) that returns me the information I need.
I like this method for learning purposes because it’s a simple app that enables me to dive deeper into the language/programming environment than most examples people use.
On the first window it lists my favorite stocks, and it has a button to update their prices. I plan on automatizing it soon. The other screen lists all available stocks, a checkbutton to mark it as monitored and a search field.
Simple as that.
Everything is build using HTML, Javascript and CSS. In fact, it’s just a web page rendered by WebKit engine.
In this app, I used a small Ruby code to use open-uri and ping libraries, so I could check internet connection and open Yahoo Finance’s download quote feature.
The design was inspired (ok, almost copy/paste inspired) by Tweetie. I hope they don’t mind.
What I think Titanium needs improving
As a new user, I really missed a good documentation. At Titanium API you find, just that, the API. There isn’t much more than that.
For example, I couldn’t find anywhere where the database is stored. At first I though it was inside your application resources, but it isn’t. After a good while looking for it, I found the it’s at ~/Library/Application Support/Titanium/appdata/your.app.context/your.app.context_0/
Another simple thing that took me a while to figure out is that, when you install your application, it creates an empty database. As it was when you package it. So, every time your application runs, you have to find out if the database is created or not, and run an database installation script. In my case:
var db = Titanium.Database.open('Databases'); try { var test = db.execute("select count(1) from papeis;"); } catch(e) { // Create tables and inserts rows // Yeah, inside the catch block. It's awful, I know. }
Ok, not a big deal, but some warning about that wouldn’t hurt.
Another thing is that I couldn’t find a way to run background process. Every time I click on the update stock button, the application freezes a few seconds as it opens Yahoo page. I tried using Titanium.Worker.createWorker, Titanium.Process.createProcess and even tried using a lot of setTimeout calls, but none worked.
I’m still skeptical about it’s performance. My app runs smoothly here, but can’t tell how it works with bigger apps.
Still, I’m very, very satisfied.