Why Apple's Leopard is a developer's delight

When it comes to Apple's new operating system, Leopard, users are likely to notice the flashy graphics and animations, the tight integration of applications and the speed with which it churns through data. What they don't see are a large number of the under-the-hood changes that Apple built in so that its own developers -- and those who come up with third-party apps -- use all of that underlying software goodness.

Apple has always taken advantage of the fact that its own internal developers write both the operating system and the applications that catch the public's eye. Think Safari. The iLife suite. Time Machine. Each new version of the operating system -- as well as those all-important programs -- can thus offer not only new features, but seamless integration and more visual flair.

In a software ecosystem whose target audience has extremely high expectations -- from Apple CEO Steve Jobs all the way down to the newest Mac owner on the block -- visual flair and application integration with the operating system can literally make or break a developer's application.

But the result, especially when the developer tools needed to code all those programs are updated, can be astonishing.

For example, when Time Machine was first demoed at last year's Worldwide Developers Conference, the audience was understandably wowed. As the much-ballyhooed backup app launched and the desktop dropped off the screen to reveal a deep-space backdrop and countless Finder windows retreating into the cosmos, it was clear Apple had done its work with the visuals.

But Time Machine's integration with the operating system and other Apple applications was even more impressive, linked as it is to the file system and the Finder, indexed with Spotlight and joined seamlessly with Apple's legendary ease of use.

With that kind of competition, how can a small developer keep up? For those developing for Leopard, the real questions are: Can we do that, too? And if so, can we do it easily?

The answer is yes. Even developers with limited resources can take advantage of Leopard's new developer tools -- included as an optional install on the operating system's disk -- allowing them to build applications as powerful and flashy as anything coming out of Cupertino.

Leopard offers a generous number of new and improved frameworks, solid system-level foundations, new application technologies and even simpler developer tools than those that accompanied Tiger when it came out in 2005.

A bit of coding background

Frameworks are reusable software designs used by developers to add features to their code with minimal effort. The more feature-complete the framework, the less hand-coding must be done.Think of it this way: Apple has a printing framework that's already feature complete, meaning developers don't have to write their own: They simply link to Apple's. Other major frameworks include Core Audio, Core Video and Core Animation.

The latter, for instance, can be used to animate a feature in that hot new app you're building. Doing that coding by hand takes a long time, and as the adage says, time is money. Why animate by hand when you can plug into Core Animation, which will animate between set states automatically? Using this framework, all a developer has to do is create a start and end state to the elements of his program, maybe add optional interim states, and allow Core Animation to do the rest.

It's like the difference between repeatedly posing a figure for a stop-action movie; that's hand-coding animation, in a sense. Using Core Animation is akin to having the figure come to life and animate itself based on the criteria set by the developer. For developers, frameworks are a major timesaver since they allow them to spend their time more productively coding for application-specific features.

What's new in Leopard

Wiley Hodges, Apple's senior product manager for Core OS and developer tools, explained in a recent interview what Apple has been up to when it comes to making developers' lives easier.

Apple's goal in revamping Leopard's core technologies was to allow developers to concentrate on the user experience -- what you see when you use a program -- and not worry about handwriting extra code, he said. Hodges noted that one of the major new features in Leopard is the ability to write 64-bit applications.

XCode 3.0 is the first version to bring 64-bit support at the GUI level mainstream, without requiring new device drivers for hardware, he said. Indeed, 64-bit support in XCode 3.0 includes full 64-bit addressing for up to 16 exabytes of virtual memory and 4TB of physical memory, as well as 64-bit performance-monitoring tools.

The best part, he said, is that 64-bit and the current standard 32-bit versions of any libraries are actually compiled from the same code-base, saving developers the pain of duplicating their efforts. In addition to that, when developers program with XCode, they can compile their code for 32- or 64-bit modes, creating applications that will run on Intel or Power PC hardware.

Using XCode 3.0 in general is a much better experience, since Apple has streamlined its interface and made it faster then its predecessors. Some of the improvements include code folding -- which allows developers to selectively show and hide code while they're working -- and even iChat-esque instant messaging bubbles that point to build warnings, errors and break points.

Even more impressive is the Project Snapshot, which allows a developer to return a project to a certain point earlier in the development process. That allows them to experiment with their code, trying new techniques or adding features, but with a safety net.

To help developers even more, XCode's documentation now offers a heads-up display called Research Assistant. It's an unobtrusive pop-up panel that displays relevant information about symbols in the developer's code, with full documentation just a click away.

According to Hodges, Objective C 2.0 is much easier to syntax, and has garbage collection built in. As Apple spells it out it to developers: "The new garbage collector is a tuned, high-performance implementation that makes tedious memory management in Cocoa applications a thing of the past." According to Hodges, garbage collection works alongside Objective C, obviating the need to manually manage Cocoa objects in memory.

"With garbage collection," he said, "developers don't have to be explicit about which objects are swapped in and out of memory; garbage collection does this automatically."

Hodges also pointed to the new Instruments suite, which allows developers to run applications and check performance in real time, which helps optimize the execution performance in their code. The suite, for example, allows a developer to track an application's CPU load, network and file activity and memory allocations, and he confirmed that it uses DTrace to monitor performance. Even better, Instruments scales itself to the hardware on which the app is being run, so that it won't overpower the battery life of mobile hardware, for instance.

A complete package

Hodges emphasized that it wasn't just any one addition to the development environment in Leopard that is important; it's the additional features all working in concert that makes it better for developers.

While frameworks such as Core Animation -- the technology that allows the operating system's elements such as Stacks and Time Machine to work -- are easy to point to as major changes, Apple actually started at the kernel level of Leopard and worked out from there. On the way, it made sure developers could plug these new features into their apps quickly.

Every area of development was touched, including multiprocessor support -- not surprising, given Apple's use of multicore Intel processors.

"Conventionally, [the code for multiprocessor-aware apps] is multithreaded," he said, "but it's easy to get out of sync when writing in parallel. It's a lot of manual housekeeping. The new NSOperation describes operation and dependencies and the system executes automatically."

NSOperation, Apple's new API for automating multiprocessor support, also scales a computer's capabilities based on its hardware, he said. The benefit of NSOperation is that developers can write their code once and not have to worry about whether it'll run well on a Mac mini or a tricked out Mac Pro.

All those tools, and countless others, combine to allow longtime developers and hobbyists to build applications with great sophistication, and without superfluous coding. That, said Hodges, is the whole point: to make it easier for them to build the kind of high-end, third-party apps that Mac users expect.

What developers do will ultimately help define the user experience on Mac OS X. And the easier Apple makes developers' jobs, the better apps they'll build -- and the better experience users will have.

Despite some concern about the level of support Apple has offered Java developers, one thing is certain: The new XCode-based environment offered in Leopard provides a powerful set of development tools. "I'm excited to see how [developers] unleash these new technologies," Hodges said.

Note: We may earn a commission when you buy through links on our site, at no extra cost to you. This doesn't affect our editorial independence. Learn more.

Read Next...