Re: Cocoa and Carbon
Re: Cocoa and Carbon
- Subject: Re: Cocoa and Carbon
- From: Stefan Werner <email@hidden>
- Date: Wed, 14 May 2008 09:35:57 -0700
On May 14, 2008, at 7:21 AM, Gerriet M. Denkmann wrote:
I always thought that Cocoa is an Objective-C API, which is a more
convenient counterpart to the more verbose or more cumbersome C API
of Carbon, which often gives more detailed control though.
You would hope that Cocoa and Carbon are just two interfaces to the
same back end code, but unfortunately that is not the case. The two
frameworks did move closer to each other over time, but they don't
relate to each other like for example MFC/Win32 or GTK+/gtkmm do.
They're not just two different APIs, they're two separate frameworks.
But then there is something like a "Carbon application" which seems
to be different from "application which uses (mostly?, exclusively?)
the Carbon C API".
For example, there is NSApplicationLoad, which is the "Startup
function to call when running Cocoa code from a Carbon application."
So: what is the real difference between a "Carbon application" and a
Cocoa one?
It's a bit of a blurry line, since you can call Cocoa from within
Carbon and vice-versa. In fact, on OS X 10.5 the Carbon calls for file
and print dialogs call Cocoa internally and Cocoa menus use Carbon
internally.
Personally, I draw the line between what the main application event
loop is and where the menu bar comes from: if it runs
NSApplicationMain() and instantiates its menu from a Cocoa nib, I call
it a Cocoa app, if it runs RunApplicationEventLoop() and creates its
menu bar from a Carbon nib, I call it a Carbon app.
Why would one create a Carbon application?
Because one wants to? It's about using the right tool for the job,
sometimes Cocoa is the right tool, sometimes Carbon is.
If your question can be rephrased as "Should I create a Carbon
application?", the answer is most likely no. When starting an OS X
application from scratch, I think pretty much everyone agrees that
Cocoa is the better choice at the moment (use it with Python or Ruby
if for some reason you don't want to or can't use Objective-C). If you
should run into limitations, you still have the option to use Carbon
for those specific parts of your application that need it.
-Stefan
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden