PDA

View Full Version : Overview of Apple development technologies




esd
Apr 2, 2008, 11:45 PM
Does anyone know of a nice overview document of how the various Apple frameworks work together? Ideally with examples of why you would choose Cocoa over Carbon... Core Foundation vs Foundation? Core Data?

I'd like to write a simple command-line OS X app to start with, but it's taken quite a bit of trial and error just to figure out what framework & language to use.

Am I just being dense?



mduser63
Apr 3, 2008, 12:36 AM
My advice: use Cocoa. Seriously, Cocoa is definitely the first-class framework going forward. Carbon is very much related to the old classic APIs, and I think we're starting to see it begin its slow death with the lack of a 64-bit version in Leopard. Core Foundation underlies Cocoa and Carbon and for the average Cocoa developer probably only needs to be considered when mixing a little Carbon into your Cocoa (which is entirely possible and not at all difficult, BTW). Foundation is the standard Objective-C classes like NSString, NSNumber, NSArray, etc. Core Data is part of Cocoa, don't think of it separately.

In short, learn Cocoa and Objective-C if your goal is to become a Mac developer. Cocoa is the highest level, most modern API, receives the most attention from Apple and IMO is by far the easiest to learn and use. It also has the side benefit of being (nearly) the same API as is used on the iPhone and iPod touch.

Finally, worth noting that Cocoa is for GUI apps. For a command-line app, you shouldn't need anything more than Foundation if you're using Objective-C.

esd
Apr 3, 2008, 10:05 AM
Thanks mduser! That was helpful.

Objective-C looks simple enough, though I already know Ruby. It appears that you can use Ruby to talk to Cocoa. Do people actually do this, or is it more of a gee-whiz thing?

whooleytoo
Apr 3, 2008, 10:35 AM
I'd be a little wary of relying on a Ruby-Cocoa bridge. Once upon a time you could code Cocoa in Java, then Apple dropped it.

The only thing you really can 100% rely upon is Objective-C - Cocoa. However, if you plan on using Ruby to learn Cocoa, and then progress onto Objective-C, that'd be a sound plan, IMO.

hhas
Apr 3, 2008, 01:55 PM
Carbon is very much related to the old classic APIs, and I think we're starting to see it begin its slow death with the lack of a 64-bit version in Leopard.

This is misleading: most Carbon APIs are supported on 64-bit. The main exception is its GUI-related APIs, which are 32-bit-only and best avoided for new development.

I would agree that Cocoa is generally a better choice for new development as it's a nicer API to work with, although there are still some tasks where the Carbon APIs are the better or only choice.

Finally, worth noting that Cocoa is for GUI apps.

I think you meant AppKit - 'Cocoa' includes Foundation, AppKit and various other APIs.

I'd be a little wary of relying on a Ruby-Cocoa bridge. Once upon a time you could code Cocoa in Java, then Apple dropped it.

Your concern is understandable, but unwarranted. The Java-Cocoa bridge was a proprietary Apple technology, and once Apple abandoned it there was nothing its users could do short of reimplementing it from scratch. OTOH, RubyCocoa is an open source project that has been available for several years now, and while it is nice to see it bundled in Leopard it is no more dependent on Apple for its future survival than it was before. Ditto PyObjC, which has been around since NeXT days and still going strong (and which I'm happy to vouch for, having successfully used it myself).

Incidentally, there's now an open-source project underway to port Ruby to the ObjC 2 runtime (http://trac.macosforge.org/projects/ruby/wiki/MacRuby), so if anything I think we'll be seeing even more interest in using Ruby for Cocoa development over the next few years.

If there's a disadvantage to using RubyCocoa (or PyObjC) rather than ObjC, it's that it doesn't yet have a sufficiently large and mature enough community- and resource-base to completely support new users in all aspects of Cocoa development (although it is growing). In other words, you'll still need to dip into the ObjC-Cocoa world at times for documentation, examples and assistance, so will need at least a passing familiarity with ObjC itself, even if you never actually code in it.

Don't let this discourage you from considering though - whether you start off with RubyCocoa (or PyObjC) or come back to it after cutting your teeth in ObjC, it also provides some advantages over ObjC, such as additional library support (since you've got access to thousands of Ruby modules in addition to ObjC frameworks) and a better platform for rapid application development and prototyping (since you don't have an extra compile step to go through when test-running your projects).