A developer's-eye view of Leopard

Steve Jobs had a lot of fun at Microsoft's expense over Redmond's difficulties shipping the operating systems that have become Vista and Windows Server 2008. So with Vista shipping by default on new PCs and Windows Server 2008 in a publicly downloadable beta, Apple should be catching hell from the press for making Leopard the last to arrive.

But the press never gives Apple hell about anything, and there's nothing like a fresh, closed beta of Leopard to put Mac developers in a forgiving mood.

Now that I've done my objective journalist's duty with an ineffectual finger-wag at Apple, I'll confess that, personally, having the beta release of Leopard set aside for paid members of Apple Developer Connection (ADC) suits me fine. I'm an ADC Premiere member. I'll be one of the 4,000 or so who'll get my Leopard DVD at the WWDC (Worldwide Developers Conference), but far more important is the week of hands-on education that comes with it.

That front-row seat includes a catch: Everything that Apple reveals about Leopard at WWDC 2007 is covered by a blanket nondisclosure agreement. Fortunately, Apple hasn't left many Leopard details to the imagination, so I am allowed to write at will about those features that Apple has taken public.

I have already written repeatedly, and at length, about Leopard the operating system and Leopard the user experience, but to date, I've had relatively little to say about Leopard the application platform. When it comes to the genuinely new facilities it places in the hands of developers, Leopard's riches are vast, and I'm just scratching the surface here with two standouts: Xray and Core Animation.

The spot of Leopard that gets me all charged up is DTrace, Sun Microsystems' revolutionary technology that bakes dynamic execution tracing directly into system software. Unfortunately, DTrace is as complicated to use as it is powerful. Fortunately, Mac developers enjoy an advantage that Solaris developers do not: Xray. This is no mere face transplant for DTrace. Xray is a serious developer power tool befitting the trend I see toward platform-aware, performance-oriented development. But even among developers of flat POSIX code, Xray will prove addictive.

leopard_bl1.gif
PART ONE: XRAY AND MORE

Xray's real-time and postmortem performance profiling capabilities let you record simultaneous traces of program execution, UI interaction, memory and resource allocation, and system counters such as CPU and network utilization, with a genuinely intuitive user interface that resembles a digital audio workstation. Xray can rewind its trace logs to show you a snapshot of the precise state of your application and its running environment, all the way down to the metal.

Developers don't have to recode to take advantage of Xray, so its effects will be felt across a broad range of applications. Even those mysterious, seemingly random bugs can't hide from Xray (hence its name): Just run your app until it fails, then rewind. Such tools exist elsewhere, but none can match Xray's price tag: free.

Graphics get a move on
Core Animation is certainly the most demonstrated of the new features that Leopard makes available to developers. In demos, texture-mapped tiles fly in various dazzling and perfectly orchestrated formations, each seeming to have a will and mission of its own. It seems that way because it's true: Every one of those image tiles does have distinct behavior associated with it. Will it change developers' lives? Maybe not, but Apple teases Core Animation by saying that it's suited to development on set-top boxes. As I waited to enter the WWDC keynote, I carried a tiny seed of hope that Apple would open Apple TV to developers.

If you've ever tried to write code for OpenGL or, worse still, game code that talks directly to a GPU (graphics processing unit), you quickly understand why Core Animation has developers so excited. Core Animation produces real-time 3-D-like animation using Click for larger view. Apple's blazingly fast Quartz rendering and compositing frameworks. However, it hides all of the complexity of Quartz and the rest of the Mac platform's imaging facilities. If you can see it, you can use Core Animation to map it to a rectangle and make it fly around.

24TCleopard1_sm.jpg
If you've ever tried to write code for OpenGL or, worse still, game code that talks directly to a GPU (graphics processing unit), you quickly understand why Core Animation has developers so excited. Core Animation produces real-time 3-D-like animation using Click for larger view. Apple's blazingly fast Quartz rendering and compositing frameworks. However, it hides all of the complexity of Quartz and the rest of the Mac platform's imaging facilities. If you can see it, you can use Core Animation to map it to a rectangle and make it fly around.

Core Animation really couldn't be easier to use. It's so easy, in fact, that I can see developers using it even for GUIs and content that doesn't move. Core Animation is, to simplify the idea, a stack of intelligent surfaces (Apple's term is "layers") onto which visual content is projected (mapped). Each surface is intelligent in that it can have developer-defined motion and transformation (that is, shrink, stretch, flip, transparency) paths that play out autonomously.

By stacking and linking these surfaces, it's possible to have dozens or hundreds of flying images that behave very much like multilayered effects one would create in Final Cut Pro, but without the extra tools. And what Core Animation does, it does in real time.

Core Animation is not a GUI toolkit; surfaces cannot be made directly sensitive to user interaction. However, because Core Animation just creates a 2-D on-screen image, and the position of every surface is temporally deterministic — you know where a surface will be at a given time — developers can map mouse-click sensitivity to Core Animation elements just by watching for mouse and keyboard actions for the entire rendered area.

Apple has also updated base UI window classes so that they can use motion and even incorporate Core Animation layers as part of their presentation. Apple makes extensive use of Core Animation as a user interface technology in core Leopard features such as Quick Look rich document preview services and the Stacks Dock-based folder navigator.

The relative ease with which this can be done paves the way for unimaginably beautiful, knowledge-dense, and productive user interfaces and information displays, not to mention the value in entertainment and consumer electronics software

24TCleopard2_sm.jpg
Click for larger view.

It is possible to replicate Core Animation in Tiger, but it would require enormous effort. Tiger developers can get a preview of sorts by playing with the Quartz Composer tool bundled with Xcode. In fact, Quartz Composer animations can be used as Core Animation layers, creating movement within movement that can also include Core Image filters and distortions. Apple's demos don't do Core Animation justice.

See it, show it, send it
Two more goodies round out Leopard's eye-pleasing developer features: Image Kit coalesces the most commonly used elements among all of OS X's image rendering and manipulation facilities into a single framework, and iChat Instant Message Framework allows developers to render arbitrary visual content that iChat automatically encodes and streams to participants in an iChat conference.

Apple's iChat Theater makes use of this facility to share images, presentations, and full-motion video with conference participants. iChat Theater's approach to content sharing is much cleaner, more bandwidth-efficient, and more secure than the full-screen sharing commonly employed in online conferences.

Image Kit provides simple high-level interfaces for taking snapshots with iSight Webcams, displaying slideshows, modifying images, and applying Core Image transformation filters. Again, these are facilities available to developers working on OS X Tiger, but only through the rather painstaking hand-knitting of multiple facilities. This sort of thing is easy for highly experienced Mac developers.

Platform newcomers, as well as developers in a hurry to get solutions to market, will find that Leopard not only provides unique and highly innovative facilities, it exposes them in ways that welcome developers of all stripes. As a result, Leopard's new features will be taken up extremely rapidly by developers, extending the transformation of the Mac platform from the OS all the way up end-user applications.

PART TWO: XCODE AND OBJECTIVE-C

Apple has always been pulled in different directions by factions of its user and developer communities. Set-in-their-ways Mac developers whose experience predates OS X have a predilection for the C language, legacy Carbon function libraries, and esoteric development tools in the tradition of Macintosh Programmer's Workshop and CodeWarrior. Meanwhile, Apple's UNIX developers and emigrants from Linux go for C and C++ for native code and Python, Perl, and Ruby for dynamic apps, and demand a command line toolset and source code portability so that they can assemble the tools they prefer. And then there are those doing Java client development and programmers writing AppleScript programs who bring their own expectations to tools.

leopard_bl2.gif
But the most influential branch of the Mac developer family tree is that which wholeheartedly buys into Steve Jobs' vision of a Mac platform melded with Unix and the pervasively object-oriented NeXT environment and toolset. These developers use Objective-C, a native compiled language with dynamic properties; Cocoa, the core framework that is the Mac platform's object-oriented API; and Apple's Xcode IDE (integrated development environment). They write the vast majority of commercial Mac software, both inside and outside Apple.

With Leopard, Apple makes its most concerted run yet at drawing developers into creating applications that exploit the full Mac platform, starting with Xcode 3.0, a dramatic set of enhancements to Apple's free and official IDE. Xcode will be publicly released with Leopard, and it is available now to paid members of Apple Developer Connection.

Polishing Xcode 3.0

IDE editors are often burdened by new features, so I was wary when I learned that Xcode 3.0 was getting an editor overhaul. However, the changes Apple made are aimed at consolidation, not added complexity, and the new editor puts out a very comfortable welcome mat for developers who aren't big fans of IDEs with crowded toolbars and jarring edit/build/debug modes.

Recognizing that a great many Unix coders live in their editors, Apple decided to bake a lot of traditional IDE functionality into the editor itself. For example, after building a project, the developer can see errors and warnings in their code without opening a build messages window.

Inline balloons point to the locations of errors. During debugging, the editor window becomes the interface for exploring symbols at run-time and for the setting and clearing of simple and conditional breakpoints. And during the all-important editing process itself, Xcode 3.0 aids without interfering thanks to the integrated Code Sense and Research Assistant.

Code Sense code completion is familiar to most IDE users, but Xcode 3.0 now presents a drop-down list of completion options; the selections narrow as the user continues to type. Xcode's innovative code templates lay out fill-in-the-blank statement completion; merely navigating inside the editor is sufficient to perform context-sensitive documentation lookups. Research Assistant, which runs in its own window, displays a summary paragraph from the on-line documentation for any highlighted keyword.

thumb89405.jpg
Click for larger view.

Also of interest to those developers new to the Mac -- and possibly to object-oriented development -- are improvements that speed the editor's handling of large source code files. Apple claims to open and scroll through big monolithic code files up to 10 times faster than before.

Lastly, Xcode incorporates code folding, which collapses sections of code (such as a function or object definition), as well as block highlighting features that distinguish logical blocks of code through shading.

Beyond the editor, Xcode 3.0 has a number of new "grown-up" features that are hard to come by in noncommercial environments and were previously non-existent for Objective-C. One is refactoring, which allows a single code change to ripple through an entire project. Xcode 3.0 refactoring obviates the need for file-by-file find-and-replace after renaming and restructuring classes. It also updates existing Objective-C code to take advantage of Objective-C 2.0 enhancements.

thumb89406.jpg
Click for larger view.
1 2 3 Page 1
Page 1 of 3