Monthly Archives: February 2006

Cocoa and Objective C

I am currently writing a graphical user interface (GUI) for my Wavelet Image Compression Library that will allow for selecting and inspecting compression settings. As my “main computer” for the past year has pretty much been an Apple Mac mini (with an x86 laptop for Linux (work) and Windows (games)), I decided to write it in Cocoa, learning the Objective-C language and the Cocoa class library / ApplicationKit at the same time.

I quite like the language (ignoring the message send syntax in square [] brackets) as you’re always aware when you’re doing OO stuff like sending messages, or writing simple C-code. It is very dynamic as essentially all binding happens at runtime and dynamically (which you of course pay a speed penalty for, but that shouldn’t matter much for high-level GUI code).
The Objective-C class library (“Foundation”) is very clean, always making a distinction between mutable and immutable versions of objects, and seems very complete with all the conveniences of modern OO.
Using the Interface Builder to create not only the actual interface, but instantiate classes and bind actions / outlets is a very nice touch. You can usually get a semi-functional mock-up of your application without writing any code at all, especially when using things like Cocoa Bindings, which allows for introspection via Key-Value-Coding (KVC) conformant objects. In essence, the AppKit “knows” how to access your member variables and set them according to the rules you defined in Interface Builder.

There are also some things which aren’t so nice. Documentation in some areas is lacking (e.g. using NSTreeController without CoreData or a dataSource), some things that look simple on the surface definitely aren’t under the hood (Key-Value-Observation replacing some of my objects by proxies, but at least they remembered to properly override isEqual: ;)). Memory management is also something which my head took some time to wrap itself around properly: every object is reference counted, but the crux is NSAutoreleasePool which is a bit like poor-man’s garbage collection. My problem with that wasn’t what it does, but when it does it. Oh, and namespace support would be nice…
Today’s challenge was to extend the NSOpenPanel of an NSDocument-based application with an accessoryView. I got it working in the end, but it wasn’t trivial (subclass NSDocumentController, changing stuff around in the Interface Builder to make sure the subclass is instantiated first, creating a separate .nib file for the accessoryPanel and praying that the View gets released properly).

Most of the time it’s a joy to work with, and a welcome change of pace from the dreadful writing of Windows GUIs in MFC. I only wish a decent Objective-C compiler with Foundation class library were available there as well (GNUStep doesn’t count, unfortunately). Might be an interesting idea to try to get Objective-C working on Microsoft’s .NET platform…

Shadow of the Colossus

Last week, Shadow of the Colossus finally came out in Europe. It’s a PS2 game by the same team which did the excellent ICO, and it shows.

It also is very hard to talk about it objectively, as it is a very subjective experience, but definitely one that you should try (in addition to ICO), as the games seemingly take place in the same world.

Essentially, the game offers you 16 boss battles (and plenty of replay incentives after that). These are sometimes more, sometimes less frantic, but always distinct episodes, separated by calming travels through the gorgeous but largely barren landscapes (which are barren for a reason; also note this does not imply boring) presented entirely without load times.

Beautiful is not a big enough word to describe how the game looks, but it pays for its epic scale with a less than stellar (but never hindering) frame-rate. I’ve entered a cave, where a waterfall falls out from a shadowed ledge into the bright sunlight that’s entering the cave from above. Or the small touches, like the doves near the altar flying off and leaving feathers behind, sea-sawing slowly to the ground, or the beauty of the water, both being below the surface or simply seeing the blurry reflections.
The animation of the main character, his horse (which you really only have to nudge where you want him to go), and the colossi themselves are moving incredibly well, with a precision and connectedness to their environment (via inverse kinematics) that is rarely seen.
Hats off to the artists and directors (not to forget the programmers, who made it all possible on aging hardware); this game has evoked emotion and thought from me on a scale I find hard to believe.

The gameplay probably won’t be to everyone’s taste (best described as a mixture of action and puzzle game), but give it a chance to enchant you. Most highly recommended, both as a game and a story.