Dynamic OS X Programming

I am very fond of Mac OS X’s graphical interface. As a GNU/Linux or FreeBSD user, i despise GUIs and usually work in a mostly text-based ambient powered by Emacs running inside a urxvt terminal. Things change dramatically when i enter OS X. There i discovered that it is not that i dislike GUIs, but that i dislike ugly GUIs (although the jury is still out on where i’m more productive).

Thus, OS X is the only environment where i feel like programming a GUI. From a programmer’s viewpoint things also start out better: one can go native and avoid C and C++. Cocoa’s native language is Objective-C, which happens to be a dynamic language. That is, one has a runtime where possibly dynamic objects live, good (but not great) reflective capabilities and a meta layer that let’s you, for instance, access class and metaclass objects. And all that at runtime. That allows (besides the fun of programming) funny tricks, like the ability to interact with running applications from the outside, in what constitutes an incredibly flexible plug-in system.

Probably the description above rang a bell: Smalltalk. Objective-C is a scaled down Smalltalk in many ways. The good news is that you can have the real thing: F-script is a Smalltalk dialect specifically designed to script Cocoa applications. It let’s you inspect any running Cocoa application, and manipulate the objects it contains in real time, so to speak. F-Script Object browser As any decent Smalltalk, it comes with a powerful object browser, which you can admire in all its beauty below. Moreover, F-script can be embedded in your Cocoa application, acting as an excellent extension language, way more cool than Apple’s default scripting language. A beautiful application taking full advantage of these abilities is ObjectiveCLIPS, a powerful rule-based development environment for Cocoa.

But still, to my knowledge, you cannot program a whole application in F-Script and, besides, Smalltalk is all very well, but it’s not Lisp. Support for Lisp in the Cocoa world is not as good, but shows promise. First, there’s OpenMCL, an excellent Common Lisp implementation for the Mac and Unix systems that comes with a Cocoa bridge. It includes a demo Cocoa IDE to get you started, and people have gone as far as creating games using it.

Until recently, poor Schemers were left in the cold. Enter Chicken and its Objective-C egg. Support is still rudimentary, but there’s already a nice tutorial on writing a currency converter, the default Cocoa Hello World app.

Probably, it’s still too hard to write a well-integrated Cocoa application using Lisp, but i think it’s just a matter of time. Happy hacking!

Tags: , , , ,

2 Responses to “Dynamic OS X Programming”

  1. Bob Hutchison Says:

    You should have a quick look at LispWorks Common Lisp for OS/X. It is a commercial common lisp, but there is a free personal use version. It comes with two ways of building a GUI on OS/X: CAPI a cross platform GUI toolkit; and a Cocoa binding that lets you attach applications written in CL to user interfaces built with Interface Builder.

  2. Jim "Zb" Ursetto Says:

    Thanks for mentioning my Objective C egg for Chicken. Although it’s still basic, functionality has been improving. I just released an update with quite a few new features, which you can read about in the version 0.4 changelog. I’m also writing up some plist manipulation code and hope to have it out soon.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: