A developer’s-eye view of Leopard, part II

reviews
Jun 15, 20076 mins

Leopard's Xcode3.0 integrated development environment and Objective-C 2.0 language help define the Mac platform

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.

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.

thumb89405.jpg
Click for larger view.

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.

Click for larger view.

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.

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.

Lastly, Xcode 3.0 strengthens the IDE’s integration with third-party SCM (source code management) facilities. Developers can check files and projects in and out, create new source tree branches, and import and export files to and from the SCM. For those projects that don’t call for full-blown SCM and to recover from unintentional mangling of checked-out files, Project Snapshots let you capture the state of a project so that something like a “global undo” can be done after something goes very wrong.

Objective-C gets an upgrade

Objective-C 2.0 is an update to Apple’s “official” language for the Mac platform. Apple recognized that the language can impose an intimidating learning curve on C, C++, and Java developers, so it introduced features that are more in line with C/C++ coders’ experience.

The greatest of these features is garbage collection. The bane of Mac developers’ existence is the need to manually track memory and resource allocation during the course of an application’s operation. That becomes a big challenge as objects are passed around by reference. Garbage collection addresses this by automatically freeing resources and allocated memory when they’re no longer needed. It takes a toll on performance, but nothing near the penalty imposed by a move to a dynamic language like Java or C#.

Objective-C 2.0 adds a “for” keyword that vastly simplifies enumerating through a collection of objects. It also adds object properties, a technique that I came to appreciate in JavaScript that allows the creation of new member variables using object.member syntax.

Taken as a whole, Xcode 3.0 and the updated Objective-C form the foundation of Mac platform development. They continue to welcome existing Mac developers, greatly enhance the experience of developers who embrace the full platform, and bring up developers who are more attuned to the old school of big code and simple editors. The result will be more high-performance native-code applications for the Mac, and that will be a windfall for Mac users post-Leopard.

Additional resources

Review: Leopard Server: The people’s UNIX

Mac OS X v10.5 is true UNIX on the inside, novice admin friendly on the outside, and born for collaboration, with turnkey-simple blog, wiki, IM, and calendar services

Review: Mac OS X Leopard: A perfect 10

Apple’s new operating system and its massive new feature set challenge users and developers to explore new and better ways of working

A developer’s-eye view of Leopard, part I

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

A developer’s-eye view of Leopard, part II

Leopard’s Xcode3.0 integrated development environment and Objective-C 2.0 language help define the Mac platform

A developer’s-eye view of Leopard, part III

Cocoa and other sweet object-oriented frameworks magically make all Mac apps part of an integrated suite A developer’s-eye view of Leopard, part IV 64-bit Darwin, Dashcode, Time Machine, and Ruby on Rails call on developers to trade out established skills for new ones Tom Yager: Enterprise Mac