Paul Thurott looks at Leopard and sums up Apple's Vista envy quite nicely

I kinda hinted at how lame the Vista bashing was in my first post about the WWDC. Well, Paul Thurott basically says everything I would have to say quite nicely here in his OSX Leopard preview. I can’t wait until certain other features are able to be talked about because it’ll be really fun to compare those to existing technologies. :P

Anyway, like Paul, I think OSX is great and really enjoy using it. In fact I’ve gotten so used to using the OS all last week, specifically the command key, that transitioning back to Windows was initially a bit of a challenge! ;)

WWDC Day 2: Apple playing catch-up in technology

So, I can’t talk about anything that isn’t already on the web because, unlike a PDC, everything you learn at WWDC is considered private. What I can say is that while OSX is undeniably kicking XP’s ass and probably going to still come out on top of Vista in terms of user experiece, they sure are lacking in the technology areas.

They’re making great strides in the languages and tools department. In this area it is quite funny to hear them still try to talk trash against C# and Visual Studio because honestly they are living in the Stone Age in some respects. First off, they’re introducing Objective-C 2.0 (see blurb in right hand corner of this page). They’re giving in to the garbage collection craze and are adding things like properties and enumerators into the language as first class citizens. They’re taking some different approaches to GC than .NET however… sheesh, I wish I could get more specific, but I have to bite my tongue for now.

Next, they’re updating Xcode, which is the standard Apple IDE, to support some really nice features that have been around in VS for quite some time. What I must give them serious kudos for though is their new debugging environment called XRay (also on that page near the bottom). That thing is seriously cool and kicks the crap out of any of Microsoft’s debugging tools. Another example of where Apple nailed the visualization of data in an intuitive way that Microsoft just never seems to be able to do.

Finally, they are also coming out with a new “Core” framework called “Core Animation” that aims to provide the equivalent of WPF for OSX Leopard. Again, I can’t talk about specifics, but from what I’ve seen it’s got some advantages as well as disadvantages over what WPF provides.

The future sure looks bright for Apple developers! I look forward to being able to take advantage of all this new, great stuff.

WWDC Day 1: Vista Under Fire

Well, I’m back in my hotel after a big Day 1 at Apple’s WWDC. Before the keynote was even started, people gettig on line were greated by three huge banners promoting Leopard. Makes sense, this is after all the big unveiling, but what was more interesting is that the taglines for these banners, rather than touting something cool about Leopard itself, all poked fun at Vista. They read:

Introducing Vista 2.0.
Redmond has a cat too. A copy cat.
Hasta la vista, Vista.

If you watched the keynote, you also saw them poke fun at Vista UI enhancements and other features that resembled things already in OSX. This was a common theme throughout all the presentations today. While I have no problem finding humor in it, it does at time get repetititve and I can’t help but wonder what their obsession with Vista is. They’ve got a great product and the future sure looks bright (though I’m not allowed to talk about anything I’ve seen outside the keynote, but that’s a subject for the next post). I think they need to move on from the whole MS bashing fascination and start promoting the product for what it is on its own.

Of the things I can talk about, the coolest thing they showed is the Time Machine backup mechanism. Not because the backing up technology is all that exciting or even new, but because of the intuitive and fun interface they slapped on it. This is where Apple beats Microsoft every single time and will continue to do so until Microsoft focuses more on the user experience and less on delivering new plumbing technologies so frequently. I sincerely hope this will happen post Vista. Once Vista is delivered, Microsoft needs to do nothing but focus on visible, end-user enhancements for the next six or so OS releases and those six releases should happen in the next three to four years. They’ve invested in the future by building a great foundation with the Vista kernel, .NET and W*F pillars. Now all they need to do is put it them use.

Objective-C, object communication patterns and the Cocoa API

Yes, another Mac post. Is this nuts or what? :)

Anyway, I’ve been doing more work with Obj-C and the Cocoa APIs. Specifically I’ve been figuring out how to use NSAlert (the equivalent of MessageBox in WinForms) and also how to work with their networking APIs to do things like GET and POST. While these things may not seem to be related, what they do have in common is the communication between objects.

Now, for the .NET audience, we have delegates which is as the equivalent of strongly typed function pointers. Most of the time delegates are used to implement events and then we have the basic pub/sub pattern of event notification.

Well, first off, Obj-C doesn’t really have functions so to speak because it is a message based language, therefore there is no such thing as a function pointer. So Cocoa uses a few common patterns to enable communication between objects:

Delegates:
This works by handing someone an instance of an object, referred to as the delegate, and that object is expected to implement an interface. Now… there’s not really interfaces in Obj-C either (not in the strongly typed sense that we think of them in .NET). There’s just this concept of a loosely defined contract of messages which you can selectively “opt-in” to implementing. They refer to this as an “informal protocol”. So basically if you only want to handle one message in this contract you just implement that message signature (down to the exact message name) on your delegate and it will be called. Any other messages in that informal protocol that don’t have implementations will essentially be no-op’d by the caller.

There’s really no direct equivalent of this pattern in use in .NET to be honest. It’s essentially leveraging the power of messaging to do it’s work. I don’t exactly like the approach, but I get it. 

The only negative to this pattern is that you may only have one delegate listening to you this way. If you wanted multiple people to be notified you’d have to use something called “notifications” that is detailed below. One aspect that they tout being especially great about this approach over notifications is that you can return values that indicate what the sender of the message is supposed to do. The same is true in .NET technically since you can’t return a value from a multi-cast delegate (aka event). However there are patterns that use the event arguments to communicate state. .NET has CancelEventArgs for this type of thing and the same pattern is used in DHTML (see stopPropagation/preventDefault) and WPF (see RoutedEventArgs::Handled) to indicate whether the logical event should continue.

Target/Action:
Probably the most familiar pattern to a .NET person. Basically think of the scenario where you have a Button and you want to know when that button’s clicked. We all know how to do that in .NET right? Just implement a method that matches a particular signature, defined by some event handler delegate, and hook it up to the instance’s event.

What happens in Cocoa/Obj-C is that you hand someone an instance of an object, referred to as the target, and a “selector” which indicates exactly what message you want sent back to object when the action occurs. The message just needs to take the same parameters as the defining action message signature, but can be named something different. This is almost exactly the same as using delegates to listen to events in .NET, but it’s a little different because, unlike delegates in .NET, you must specify these two things separately to the object you want to notify you. Also, the message contract is again little more loosely defined.

While this pattern makes certain things very simple in the Cocoa world, there’s two pitfalls with this approach that I see:

  1. No way to have more than one listener in this pattern.
  2. You can basically have only one action in this pattern, which means for a button you can have it fire it’s “click” action in this way, but all the other stuff like handling key presses and mouse overs requires you to go back to using the delegate pattern anyway.

Notifications:
Notifications are basically the closest thing to .NET events from a conceptual point of view, but are very different from an implementation point of view. They’re similar because they allow multiple subscribers and the signature of the method is void since the result of each of the subscribers is meaningless. That’s where the similarities end though.

Notifications are implemented by describing a message whose signature takes a single parameter of type NSNotification.

I'm going to AWWDC

What… you don’t know what AWWDC is? Well, make sure you’re sitting down because this may come as a shock. It’s the Apple Worldwide Developers Conference. *insert record scratching/squealing tires sound here*

Seeing as how I’m like Mr. Microsoft when it comes to software the most common reaction to this is probably “Woahhhhhhhhhhh, what the…?!?” Well… it’s for the good of the company. Basically MacOSX has become attractive to us over the past couple of years for two reasons:

First, from the server perspective, the platform has a much richer set of APIs for working with PDF content than are available for the Windows platform. Today Mimeo’s workflow is entirely PostScript today. PostScript is great for printers, but sucks for everything else we need to do. So we end up having to cobble together a bunch of third party and open source libraries to solve all kinds of problems because none of them do everything we need. Therefore we’re planning on moving to a PDF workflow instead. OSX’s native graphics API, Quartz, is fundamentally tied to PDF. We know that they have done (and will continue to do) a lot of work to make sure they support every possible facet of the PDF specification. Personally, nothing would make me happier than to move to an XPS workflow, and we are engaged with Microsoft to investigate the possibilities of that, but I just don’t think it’s going to happen because the industry support just isn’t there fore the types of hardware we’re using. Timing is everything and XPS just doesn’t seem mature enough for Mimeo to adopt at this point… I guess we’ll see.

Second, as a client platform, there’s no denying that OSX usage is growing. As a small company with limited resources we kinda had to shrug it off in the past because from a business perspective we were trying to be the best at a very specific portion of the printing business: 81/2x11″ business documents. The people using OSX usually have different printing needs because it is typically a much more creative crowd. :) Well with all the growth OSX has had, clearly it’s not just the artist types anymore and we need to do what we can to give them the power of Mimeo.

What does this mean for me? Well, in the approximately 20hrs I’ve spent working with it I’ve learned…

  • … more about OSX than I’ve ever known about any Apple platform in my life – technically it’s just another *nix machine under the covers so I can use all those fundamentals, still just not a fan of the way the windowing UI works generally, but then again a lot of other facets of the UI work better than Windows
  • the basics of Objective-C – it’s a fun language, has a lot of “funkyness” to it, very similar to COM in terms of memory management, but they have this interesting concept of an auto-release pool which is a stack based automatic memory management
  • the fundamentals of Cocoa – Cocoa is basically the MFC or WinForms of OSX. I know what a NIB is, what outlets and actions are, learned some of the basic patterns used in Cocoa and I’ve put together a working application
  • how to work with XCode – this is the Apple supplied IDE for OSX development which I guess is the equivalent of Microsoft’s Visual Studio, but no where near as nice
  • how to work with Mono on OSX - I use my favorite language (C# of course ), get all the benefits of the BCL and for UI I just use Cocoa#. This has enabled me to do rapid prototyping because I avoid having to code in Objective-C right now.

In the end though I probably won’t be writing the actual software that gets delivered to the desktop, since I believe we’re going to outsource the work to an OSX specialist shop. However, as Chief Software Architect, I consider it my responsibility to understand and talk intelligently about the technologies involved and, ultimately know what is possible and what isn’t.

From what I’ve learned so far, OSX is a pretty nice platform to develop for. Granted I haven’t gotten down and dirty with lower level concepts like threading or IO yet, but, I’m impressed thus far.