Downloading and Building Cappuccino 0.7b on OS X Leopard

As you may have read already, I’m in the process of learning and developing web applications with Cappuccino. I’ve been building against the latest stable release of Cappuccino, which at the time of this writing was 0.6.5, and I saw the Cappuccino team released a new version: 0.7 beta. I wanted to play with 0.7b, to see the new features and possibly contribute to testing.

Right now, the only way to use 0.7b is to download and build it from source. Since I develop on a MacBook Pro using Mac OS X Leopard (10.5), these instructions will be based on that. These instructions also assume you are familiar with the Terminal application.

Prerequisites

You will need the following:

  • Git
  • Ruby, Rubygems and Rails – If you’re using OS X Leopard, the default install that comes with the OS is sufficient. (Cappuccino will not compile on Ruby 1.9, make sure you’re using Ruby 1.8)

Installing Needed Gems

Cappuccino 0.7b requires the plist Ruby Gem. The installer is supposed to automatically install it for you, but it can be flakey, so just for safety’s sake, install the plist gem by running the following command:

sudo gem install plist

Getting the Source Code

Once you have Git and Ruby installed, you need to get the source from the Cappuccino project on GitHub. I keep all my source code in /usr/local/src/ (for more info on why, Hivelogic has an article about this very subject).

Let’s go into the src directory and check out the source code

cd /usr/local/src/
git clone git://github.com/280north/cappuccino.git

This will download all the source and create a directory name cappuccino. Let’s go into that directory and select the 0.7b branch as the active target.

cd cappuccino
git checkout -b 0.7b origin/0.7b

This sets 0.7b as the current target.

Building the Cappuccino Code

Now, let’s go ahead and build the code

rake release

This should have built Cappuccino 0.7b. You may have experienced the following error while trying to build the code:

subrake missing: ojunit

If so, don’t panic. It’s just looking for additional software, build by the Cappuccino team, that isn’t provided in the Cappuccino source by default.

Just run the following commands:

cd Tools
git clone git://github.com/280north/ojunit.git
cd ..

Then run

rake release

again and you should have happy compiled code.

Installing the Cappuccino Code

Now, to install the Cappuccino tools, you just run the following command:

sudo rake install

This will install all the Cappuccino binaries in /usr/local/bin/. This should already be in your PATH, so you should be able to run the Cappuccino binaries.

Using capp

Building and installing the Cappuccino code created some new useful tools for you. One of them is the capp application that generates all the Cappuccino frameworks and shell code for you. It can also be used to upgrade the frameworks in your existing application.

Creating a new Cappuccino Application

You can use the capp application to create a new Cappuccino application for you. From within any directory you want your new cappuccino application created, just issue the following command:

capp Application Name [options]

If, for instance, you want to create a new app called “HelloWorld” to be placed on your desktop, then you can easily enter the following command:

capp ~/Desktop/HelloWorld

This will create, quite literally, a Hello World application. You can use this as the basis for your app and build on top of it.

Upgrading an Existing Cappuccino Application

If you already have developed (or are developing) a Cappuccino application and you just want to see how your application will function in the latest beta, the easiest method is to create a dummy application with capp using the instructions above, and then just replacing the Frameworks folder in your application’s folder with the new one created by capp.

Building Better Web Apps in Cappuccino

Believe it or not, we have several applications built using Excel and Excel macros that employees at SPARTA use. So each time we update the Excel file, we have to send it out to the users manually. There are issues with these apps running in Excel 2007 that we haven’t fixed yet, so whenever someone inadvertently upgrades, we have to get them to downgrade to Excel 2003.

So for many reasons, we’re replacing these Excel-based apps with a web-based system. As is typical with SPARTA, we’re the exception to every rule, so no Commercial of the Shelf (COTS) system really did everything we needed it to do. So now it falls on us to develop the web application. One decision we’ve made was to make the web version similar to the Excel-based versions to reduce the learning curve. Then as users get used to the web apps, we’ll gradually make changes and redesigns as we find necessary.

One of the apps is mostly just a report viewer, so it will be built using a traditional XHTML/JavaScript interface to mimic the Excel functionality. Of course, we will be offering methods to export the data so the users can use the data in a way they’re more comfortable, but we’ll take care of all the calculations and data persistence on the web server.

The second web app, of which I am in charge, is mostly just a data-capture application. It needs to do a lot more than the reporting app, so we decided to go down the path of creating a full-on web application. For that, we have decided on developing the app in Cappuccino.

Cappuccino is a JavaScript-based framework for developing web applications. For anyone familiar with programming for the Mac or iPhone, it’s touted as “Cocoa for the web”. Just like how Cocoa is built on the Objective-C language, Cappuccino uses its own Objective-J language. Where Objective-C is a superset of the C language, Objective-J is a superset of JavaScript. Which means even when coding in Objective-J, you still have access to all the regular built-in JavaScript functionality, much like C functionality is available to Objective-C applications.

In fact, the Cappuccino team has already ported many of the frameworks available in Cocoa to Cappuccino. So really, any seasoned Cocoa developer could easily create a Cappuccino application with minimal learning required. The Cappuccino team even points out that one iPhone developer was able to port a game he created for the iPhone from Cocoa to Cappuccino in just one hour.

They’ve also created an impressive web application, written entirely in Cappuccino and Objective-J, that is essentially a web-based version of PowerPoint called 280 Slides.

How is Cappuccino any different than any of the other JavaScript libraries like jQuery, MooTools, Script.aculo.us, etc? Well, they all use the same basic fundamental design: you build your site using HTML and CSS, then you plug in the library where necessary. Cappuccino apps require no knowledge of HTML or CSS; it builds the HTML and CSS for you in your application. So you spend more time developing the application, and less time worrying about design or attaching your JavaScript to your HTML.

We’ve had a chance to test out and develop a few test applications in Cappuccino and I’ve been very impressed so far with the results. We’re finally moving ahead on these applications, so as I use Cappuccino and Objective-J, I will likely be posting up some thoughts and maybe some tutorials as I see fit.