Mac users have high expectations. A newcomer to the platform quickly discovers that all Mac applications share consistent appearance and behavior, are incomparably fast, and come with "Wouldn't it be great if I could …?" user interface experiments that tend to just work.
Mac developers are a remarkable lot, it's true, but they're not rolling all of this rich functionality, suite-like cross-app integration, and consistent behavior by hand. It's in the OS X frameworks. Rich text document and HTML editing, ubiquitous drag-and-drop, spelling- and grammar-checking, dictionary lookups, search, PDF export, hyperlinks, video and audio playback and recording, complex 2-D and 3-D rendering with CPU/GPU optimization, and so much more is integrated into the frameworks such that just picking a framework class to add a feature makes it Mac platform standardized and compatible.
Even when Apple supplies several approaches to achieving the same end in order to accommodate developers' various preferences, the company ensures that all those tactics result in a completely consistent user experience. No matter what software you add to a Mac, the whole system feels like an integrated suite.
Delicious Cocoa
Cocoa is the root framework, the primary API, for all native Mac applications written in Objective-C. There are wrappers and
bridges that allow using some Cocoa facilities in other languages, including C, C++, Python, and Java, but the only way to
suck all of the goodness out of Cocoa and the Mac's other object-oriented frameworks is to use Objective-C.
Now that Apple is using Objective-C for all of its application development, visual and functional elements that Apple builds into its programs are finding their way into Mac frameworks so that developers can evolve their apps into Leopard's updated look, feel, and feature set. It's surprisingly easy to do, and in some cases, developers don't have to lift a finger — not even recompile their code to add the features that weren't present in the Tiger release of their application.
The most accessible examples of the zero-effort Tiger-to-Leopard transformation are Text Services and unified window styles. In Tiger, all Cocoa applications that incorporate text-entry fields inherit OS X's spelling checker. The Cocoa framework that ships with Leopard adds a grammar checker that tries to flag awkward or improper sentence construction and various barriers to readability. Its smart quote support converts open and close quote pairs to tails-up, tails-down style in formatted documents and flat, HTML-friendly quotes for plain text. Hyperlinks found in a Cocoa text-editing field are automatically detected and rendered in a familiar standout underlined style that launches the browser by default. Multiple regions of selected text can be copied and pasted with the same ease as contiguous sentences and paragraphs. With Leopard, text attachments can also be edited inside a document being viewed without the need to pop up a text-editor window.
These might seem like small changes, but they add up to key functionality that developers previously had to code into their applications. As with all features that Apple adds to revisions of its frameworks, everything is optional, and everything can be superclassed to add functionality and make objects that implement an application-unique feature set without sacrificing consistency or compatibility.
Compelling scripts
Cocoa provides hooks for making applications scriptable, that is, usable as services by other Mac platform apps. The scripting
interface to Mail, for example, is not merely capable of invoking a message composition window. A script that interacts with
Mail can extract messages from the inbox, perform searches, and create rules to govern the handling of incoming mail. OS X
incorporates an elaborate but thoroughly abstracted dynamic remote procedure invocation mechanism for native applications.
It's based on messages, as is all of Cocoa, and is therefore far more robust than one would expect from interpreted scripts.
While Cocoa's scripting support exceeds other platforms' capabilities, it has been practically limited to script-to-application interaction, that is, invoking calls into Cocoa applications from external scripts. Oddly, as useful as it would be to do so, it's extremely difficult to invoke calls to Cocoa applications from other Cocoa apps.
In Leopard, Cocoa addresses this. A new facility, Scripting Bridge, generates Objective-C code that effectively turns scriptable Cocoa applications into objects whose methods can be invoked from other Cocoa applications; hooking two or more applications together requires no middleware. One inherits this capability simply by adopting Cocoa.
Tom Yager is chief technologist of the InfoWorld Test Center. He also writes InfoWorld's Ahead of the Curve and Enterprise Mac blogs.
Talkback
E-mail
Printer Friendly
Reprints




