Carbon, Cocoa and XCode confusion



Does somebody want to clear up my understanding on the above three? They all seem to have melted into on confusing blob of mac programming terminology.

Partly why I'm confused is that I don't have a mac yet an can't use any of the above! Soon .. not long now ....

XCode is the IDE, the application you use to write code.

Carbon and Cocoa are two frameworks, or libaries if you will, with prebuilt objects you can use as is or extend. Carbon is an old framework to be used when you want applications to run in both Mac OS 9 and Mac OS X.

To write applications for Mac OS X only, you'd use Cocoa.

There's a ton of information on Apples Developer pages:

Go check them out!
Carbon and Cocoa are two APIs (frameworks, libraries, whatever you wanna call 'em). Both are used to make native OS X applications. Carbon isn't just for backwards compatibility — in fact, most recent Carbon apps can't run in OS 9 anyway.

Most new OS X apps are made with Cocoa, because it's very modern and very easy to use. You get a lot of stuff "for free" with Cocoa, like automatic spell-checking, recent items lists, AppleScript-ability, and lots of other cool stuff. As a programmer, you don't need to do anything to get your app to have these features, whereas in Carbon, it would take a good bit of work (if it would even be possible; I'm not sure, since I've never used Carbon much).

The reason there are two APIs is because OS X is the child of two different operating systems: The original Mac OS, where Carbon comes from, and NeXT, where Cocoa comes from.

Another big difference between the two is the languages used. Carbon is based around C/C++, whereas Cocoa is based on Objective-C (XCode also includes a Cocoa-Java bridge). Because of this, and the fact that Carbon is a more old-fashioned (conventional) API, many programmers find it much easier to go from Carbon to Windows (or vice-versa) than with Cocoa. Carbon skills will probably take you further in the professional world than Cocoa skills (unfortunately), because they're easier to transfer to other systems.

Carbon programs can also potentially run in Mac OS 8/9, although most recent ones won't, anyway. Some examples of recent Carbon apps are Apple's own iTunes, Finder and QuickTime Player. The main reason they're Carbon is probably because all of them were ported from Mac OS 9. Most of Apple's programs that were created after the introduction of OS X are made in Cocoa, like Safari, iChat, Pages, Keynote, etc.

Carbon is often called a "legacy" API, but personally I think people are a bit too quick to dismiss it. It's a vital part of OS X, for both users and developers. That said, if you're making a new app for OS X only, Cocoa's probably the way to go. It'll make your life a lot easier.

XCode can be used to make both Carbon and Cocoa apps.