On the final day of WWDC, Kevin Hoffman gave a lunch time presentation on using Apple's Mac OS X Cocoa developer environment as part of a cross-platform development strategy. I've enjoyed reading Hoffman's regular articles about Cocoa in his .NET Addict’s Blog, in part because he presents Cocoa from the fresh perspective of someone new to the platform.
What I find even more interesting about his comments is that--coming from an extensive background of .Net knowledge--Hoffman offers insight into the differences in the approach and architecture used in Microsoft's .Net and Apple's Cocoa.
Hoffman not only presents a Rosetta Stone comparison of the different development environments, but does so in a way that is accessible, incisive, and engaging, even for non-technical readers. Knowing and understanding more than one approach is rare enough; being able to express the differences clearly is really remarkable.
And Now A Warning: Just Three Cylinders Firing at 20% Compression.
As a caveat to the reader: I happen to be operating in a reduced capacity the moment. Not only is it halfway through Friday--the fifth day of my crash course attention to technical details and the day after Apple's WWDC Thursday Night Beer Bash, where the beers were free as in... well free as in beer--but I've also been dealing with some sort of cold or flu, and I've forgotten whether I need to feed it or starve it.
With all the “free as in beer” food and Odwallas here, I've been erring on the side of feeding it, big time. In fact, I'm so excessively fed that I'm in a bit of a hyper-nourished flush. As if mental exhaustion, beer, all-you-can-eat snacks, and a dragging cold wasn't enough, I also managed to get hauled into karmic court for flouting the law of averages as it relates to traumatic circumstances.
One might say I am accident prone, perhaps even to the extent of being--as an individual--one of the key reasons why health insurance costs so much in this country. I visit the emergency room using an ambulance at least annually, unless I happen to be in a developing country where there are no ambulances available.
Over the last several years, I started a tradition of breaking a bone and a PowerBook laptop every January, a run that was only ended when Apple stopped shipping laptops under the PowerBook name in 2006.
This year, I thankfully managed to not break either, although I only narrowly missed destroying my Mac Book Pro last night. Instead of falling on it, I instead fell on top of a glass mug--I can't explain how or why--that shattered and subsequently sliced open a hole in my lower back the size of a gaping maw on a giant catfish.
I should point out that did not get sloshed at the WWDC bash: it was merely a freak accident. I'm very fortunate it didn't cut a half inch deeper, as I might have ended up with a severed spinal column or perhaps even bled to death on the floor in my house at midnight, which is a really bad way to end any week, but WWDC in particular.
Such an accident makes one reconsider everything that is important. My accidents have me contemplating life so often that I may need to record my deep thoughts on philosophy in a large tome at some point.
In any event, I was up till 5 AM getting stitched up at the emergency room at San Francisco General Hospital, which is itself an adventure on the level of being in a real world rehearsal of MASH during one of its more dramatic seasons when Alan Alda was more poignant than funny.
I apologize for the extensive expositional digression.
Back to You, Kevin.
While all of the WWDC sessions are included under the broad provisions of Apple's NDA, Hoffman's presentation brought up several comments and observations he's made publicly in his blog, in his participation with Apple's Leopard Tech Talk road show, and which are not related to Apple's confidential information. For that reason, I think it is safe to outline what he has been presenting in the last several months.
Hoffman has been working with Microsoft's technologies for many years, and was an early adopter of Vista's new Windows Presentation Foundation and the .Net 3.0 framework since their release to developers back in 2003. He has literally wrote the book on a series of Microsoft development subjects from ADO.NET to C# to SharePoint. In contrast, he is brand new to Apple's Cocoa, having only worked with it over the last few months.
For that reason, it's interesting to hear his perspective on Apple development. Hoffman described his experiences in building an application for tracking people, places, things, and scenes for authors and game developers managing virtual worlds, using both WPF and C# on Vista, and the Cocoa and Objective-C 2.0 environment for Mac OS X Leopard.
.Net vs Cocoa for Developers.
Despite being an expert in .Net but brand new to the Cocoa platform, Hoffman said the time to complete his project was much faster on Cocoa. The same project took only one third the time, despite his having far more experience with Vista's .Net frameworks than Apple's Cocoa. He also noted:
The user experience developed was better by default on Mac OS X. As a programmer and “not a designer,” Hoffman says he approached user interface development with some trepidation, needing to seek out help from professional designers on the Vista end.
Under Cocoa however, Hoffman says he found Apple's visual development tools very accessible, while Microsoft's visual interface builder tool in Visual Studio was “so poor I turned it off.”
A specific example related to Cocoa's Core Animation, which allows developers to create rich, animated interfaces with very little code. Vista offers tools to accomplish similar feats, but requires developers to explicitly build every step of their animations using far more code, even to do simple things like fade out a view on a transition.
Another example was the developer support for giving users undo and redo features. Hoffman said .Net's INotifyPropertyChanges “is not enough,” requiring pre and post-change notifications to implement undo and redo. It's “not pretty,” he says, particularly in comparison to the Cocoa framework, which offers undo and redo functionality to developers “or free,” using zero code, with NSUndoManager.
Also noted was a comparison between Apple and Microsoft's desktop data stores. Core Data in Cocoa, introduced with Mac OS X Tiger, offers developers rich, flexible options for storing an application's data using XML, binary files, or an SQLite desktop database.
Isolated storage in an object relational system won't be offered for .Net until later this year, forcing developers to use XML flat files, or jump up to full blown SQL Express work, a large burden to put upon desktop application developers.
MVC Design Patterns in Cocoa and .Net.
Another difference between the development environments provided by Apple and Microsoft relates to the Model-View-Controller model. Apple has worked hard to push developers to keep interface code, data, and business logic all partitioned separately.
In many development environments, functional code, data and presentation are all mixed together. This results in projects that are difficult to manage, particularly in settings where the interface is created by professional designers, and the code is written by specialized code developers. Less structure also makes it challenging to scale projects, or adapt them to use data from other sources.
In a clean MVC model, an application can be more easily adapted to work on data from other sources, such as data in a different container format, or obtained from a web service rather than a local file, for example. If data or interface elements are tied to code, such adaptations can't happen without a major re-architecting of how everything works.
Hoffman notes that Microsoft's Visual Studio does not encourage MVC. It's too easy to stick code in views, for example, making development “spaghetti-friendly.” In contrast, Apple's Xcode “bakes in” MVC principles. There is no real choice in doing things in sloppy ways, and “that's a good thing” Hoffman notes.
New frameworks are making development of custom controls much easier. “Usually when someone suggests I build a custom control,” Hoffman says, “I run for the nearest exit” despite having a history in developing custom controls for ActiveX, COM, MFC and at least five other languages. Vista's .Net XAML and Apple's Cocoa both greatly simplify things in that regard.
A key difference is that while .Net provides a lot of power, it “doesn't do anything on my behalf,” Hoffman says, making the developer do all the heavy lifting.
Philosophical Differences.
Hoffman describes Cocoa as making “easy things easy, and hard things possible,” with a progressively sloping difficulty curve. The more complex the task, the more work is needed to accomplish it.
For .Net, Hoffman only says “everything is possible,” with a flat difficulty plateau. “Hideously complicated problems” are as difficult as the simple things, but that also means that even simple things are hard. There is no curve.
For cross-platform developers, Hoffman warns against drawing low level comparisons. Rather than trying to do things the same in both environments, a higher level view needs to be taken when approaching problems because of the differences in implementation and philosophy.
Some things in .Net or Cocoa do not need to be done in the other environment, Hoffman points out. Trying to find identical ways to accomplish the same task in different environments often leads to frustration or the misleading assumption that there is no way to accomplish things in the new and unfamiliar environment.
Hoffman points out that making low level comparisons might lead to "asking questions for the wrong reasons." Sometimes things are just different. Working in Mac OS X's Interface Builder for the first time, for example, Hoffman said he couldn't immediately see why his changes weren't visible in the newly built app, until he realized that it requires a save before actually building the project.
If you haven't yet discovered Hoffman's blog, check it out. He most recently castigated Mary Jo Foley for her “inflammatory nonsense” article comparing Mac OS X Leopard to Vista. I have some thoughts of my own on that subject, which I'll try to stitch together shortly.
Did I miss any details?
Haloscan Q107
Next Articles:
Does Leopard Look Like Vista?
BHOze and the BHOzing BHOzers that BHOze Them.
EA’s Intel Mac Games: WINE and Cheese??
This Series