Xray and Core Animation stand out among Apple's immense bag of new Leopard tricks

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.

Thank you, SunThe 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.

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.

Click for larger view.

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 onCore 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 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.

Click for larger view.

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

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 itTwo 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.