Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jan 12, 2009, 02:11 AM   #1
fab5freddy
macrumors 65816
 
fab5freddy's Avatar
 
Join Date: Jan 2007
Location: Heaven or Hell
Cocoa vs Carbon ?

I am rather new to programming and want to know
what the difference between Cocoa and Carbon are ?

thanks !
fab5freddy is offline   0 Reply With Quote
Old Jan 12, 2009, 02:14 AM   #2
TuffLuffJimmy
macrumors G3
 
TuffLuffJimmy's Avatar
 
Join Date: Apr 2007
Location: Portland, OR
carbon isn't 64bit and is going to be killed off sooner or later. Stick with cocoa.
__________________
"Next PM I get from you about this, and it gets posted as my signature." --*LTD*
TuffLuffJimmy is offline   0 Reply With Quote
Old Jan 12, 2009, 04:39 AM   #3
neonblue2
macrumors 6502a
 
Join Date: Aug 2006
Location: Port Pirie, South Australia
Carbon ---> C, C++
Cocoa ---> Objective-C
__________________
Stuff
neonblue2 is offline   0 Reply With Quote
Old Jan 12, 2009, 10:09 AM   #4
kainjow
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
Quote:
Originally Posted by TuffLuffJimmy View Post
carbon isn't 64bit and is going to be killed off sooner or later. Stick with cocoa.
Yes if you're new to Mac OS X programming, skip over Carbon, at least the UI stuff. The file/alias/etc manager still applies and can be used in 64-bit but to do a UI use Cocoa.
kainjow is offline   0 Reply With Quote
Old Jan 12, 2009, 12:21 PM   #5
hhas
macrumors regular
 
Join Date: Oct 2007
Quote:
Originally Posted by TuffLuffJimmy View Post
carbon isn't 64bit and is going to be killed off sooner or later.
First bit is wrong; second is speculation. Carbon's GUI APIs are 32-bit only, as are the Carbon QuickTime APIs; avoid these for new development. Most other major Carbon APIs are present on 64-bit OS X. Quite a few provide functionality that is absent or inferior in Cocoa.

For GUI work use Cocoa. For other other things you'll likely want to stay on Cocoa where practical, but don't be put off using officially supported Carbon APIs where you need them.
__________________
Learn AppleScript, 3rd edition, Sanderson & Rosenthal:
http://www.apress.com/9781430223610
hhas is offline   0 Reply With Quote
Old Jan 12, 2009, 01:01 PM   #6
semicolons
macrumors newbie
 
Join Date: Feb 2008
Avoid carbon until you need it, as Cocoa is the future. It has been recommended by Apple, for the past few years at least, that you use Cocoa for new development. Unfortunately, there are still some things you can't do in Cocoa, for which you need Carbon, but don't bother with Carbon until you need it.
semicolons is offline   0 Reply With Quote
Old Jan 12, 2009, 01:43 PM   #7
kainjow
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
Also, Cocoa is very mature at this point, but there are still things (for example) like checking to see if a key is down that don't work 100% in Cocoa. Normally you'd do this by checking [[NSApp currentEvent] modifierFlags] but NSApplication doesn't begin handling events until at a certain point, so if this in your app's awakeFromNib/init or similar methods, it won't work and you have to stick with GetCurrentEventKeyModifiers()... I have yet to find a non-Carbon workaround (since this won't let you compile 64-bit AFAIK).

Edit: I guess I didn't search hard enough last time. Here (see comments) is how you do it without Carbon using CGEventCreate() and CGEventGetFlags().

Anyways, my point is Cocoa still isn't complete yet. You may still need to use some Carbon APIs or other C-based ones that don't have an Objective-C wrapper yet.

Last edited by kainjow; Jan 12, 2009 at 03:16 PM.
kainjow is offline   0 Reply With Quote
Old Jan 13, 2009, 04:37 AM   #8
Soulstorm
macrumors 68000
 
Soulstorm's Avatar
 
Join Date: Feb 2005
One thing that hasn't been mentioned is that Carbon (not the GUI stuff) in general is Cocoa in plain C. You still get the retain/release methods and memory management in Carbon has many similarities with Cocoa. So, if you begin with Cocoa, when the time comes and you need Carbon, it won't be difficult to adapt to it.
Soulstorm is offline   0 Reply With Quote
Old Jan 13, 2009, 11:39 AM   #9
Krevnik
macrumors 68020
 
Krevnik's Avatar
 
Join Date: Sep 2003
Quote:
Originally Posted by hhas View Post
First bit is wrong; second is speculation. Carbon's GUI APIs are 32-bit only, as are the Carbon QuickTime APIs; avoid these for new development. Most other major Carbon APIs are present on 64-bit OS X. Quite a few provide functionality that is absent or inferior in Cocoa.

For GUI work use Cocoa. For other other things you'll likely want to stay on Cocoa where practical, but don't be put off using officially supported Carbon APIs where you need them.
Most of the other major Carbon APIs are present mostly because they don't predate OS X, and they are shared with Cocoa in some way (or were expected to be used by developers in both environments).

The key thing to remember is: if the API predates 10.0, or is GUI-related, it's gone. That really covers most of the important stuff required to do an application in pure C anyways.

Handbrake is probably a good example of how you can do a mixed C/Obj-C application: put your low-level code into a static library, and link it straight into an Obj-C GUI front-end. You get the portability of the core feature set, while staying on Apple's good side.
__________________
iMac 2013 27", 13" 2012 rMBP, iPad Air, iPhone 6
Krevnik is offline   0 Reply With Quote
Old Jan 13, 2009, 12:52 PM   #10
hhas
macrumors regular
 
Join Date: Oct 2007
Quote:
Originally Posted by Soulstorm View Post
One thing that hasn't been mentioned is that Carbon (not the GUI stuff) in general is Cocoa in plain C. You still get the retain/release methods and memory management in Carbon has many similarities with Cocoa.
This is true for newer Carbon APIs that appeared post-OS9, e.g. Core Foundation. Pre-OSX APIs use a different memory management scheme (which isn't reference-counted, unfortunately).

Quote:
Originally Posted by Krevnik View Post
The key thing to remember is: if the API predates 10.0, or is GUI-related, it's gone.
Still not quite correct; if you really want to know what's on its way out, look in the header files or on Apple's developer site [1]. e.g. Two major Carbon frameworks that I [for my sins] do a lot of work with - Apple Event Manager and Open Scripting Architecture - both predate OS X and have been updated over the years to ensure OSX and 64-bit compatibility. And I'd be pretty peeved if they went away any time soon given that their Cocoa wrappers are inferior and/or not a good fit with non-ObjC-based implementations.

I imagine folk like Microsoft and Adobe who have massive investments in C++ codebases would also have an absolute fit if any more Carbon APIs go away - I don't imagine they were overly pleased about Apple's last-minute reversal on the 64-bit Carbon GUI APIs. Apple would lose significant marketshare if those vendors decided enough was enough.

--
[1] The ones I can recall offhand are all Carbon GUI, QT, QD APIs. FSSpecs and APIs that use them are also defunct; modern alternatives are provided as needed.
__________________
Learn AppleScript, 3rd edition, Sanderson & Rosenthal:
http://www.apress.com/9781430223610
hhas is offline   0 Reply With Quote
Old Jan 13, 2009, 03:14 PM   #11
Catfish_Man
macrumors 68030
 
Catfish_Man's Avatar
 
Join Date: Sep 2001
Location: Portland, OR
Send a message via AIM to Catfish_Man
Quote:
Originally Posted by hhas View Post
FSSpecs and APIs that use them are also defunct
I wonder if this fact will ever stop making me happy. I doubt it
Catfish_Man is offline   0 Reply With Quote
Old Apr 30, 2012, 09:37 PM   #12
iAppleseed
Banned
 
Join Date: May 2011
Quote:
Originally Posted by fab5freddy View Post
I am rather new to programming and want to know
what the difference between Cocoa and Carbon are ?

thanks !
What the heck is Carbon and Cocoa? Oh, I know what Cocoa is. It's chocolate. But what does it have to do with Macs or Programming?
iAppleseed is offline   -3 Reply With Quote
Old Apr 30, 2012, 10:49 PM   #13
ArtOfWarfare
macrumors 603
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
I realize this topic was just revived by a troll, but I'd like to ask a quick question regarding Carbon...

Should I avoid it like the plague, or is it still necessary to use it ever?

I'm just learning to use a 3D graphics engine (Ogre 3D) which appears to work much better with Carbon than Cocoa (cocoa will end up having artifacting for some reason where Carbon won't,) but ultimately I'd like the game I'm making with it to be sold on the Mac App Store.

So... Figure out how to make it work with Cocoa, or should I just accept the easy solution of using Carbon?
__________________
Don't tell me Macs don't last: 2007 iMac, 2007 Mac Mini, 2008 MacBook Air, all Vintage.
(iMac obsoletion: April 28, 2015, MBA: October 14, 2015, Mac Mini: March 9, 2016)
ArtOfWarfare is offline   -1 Reply With Quote
Old Apr 30, 2012, 10:57 PM   #14
throAU
macrumors 68030
 
Join Date: Feb 2012
Location: Perth, Western Australia
Quote:
Originally Posted by ArtOfWarfare View Post
I realize this topic was just revived by a troll, but I'd like to ask a quick question regarding Carbon...

Should I avoid it like the plague, or is it still necessary to use it ever?

I'm just learning to use a 3D graphics engine (Ogre 3D) which appears to work much better with Carbon than Cocoa (cocoa will end up having artifacting for some reason where Carbon won't,) but ultimately I'd like the game I'm making with it to be sold on the Mac App Store.

So... Figure out how to make it work with Cocoa, or should I just accept the easy solution of using Carbon?
Carbon is deprecated - don't think Mountain Lion will run it?
__________________
MBP (early 2011) - Core i7 2720 2.2ghz, Hires Glossy, 16GB, Seagate Momentus XT 750GB
Mac Mini (mid 2007) - Core2 Duo 1.8, 2gb, 320gb 7200 rpm
iPhone 4S, iPad 4, iPad Mini, HTC One (eval)
throAU is offline   0 Reply With Quote
Old May 1, 2012, 02:38 AM   #15
gnasher729
macrumors G5
 
gnasher729's Avatar
 
Join Date: Nov 2005
Quote:
Originally Posted by ArtOfWarfare View Post
I realize this topic was just revived by a troll, but I'd like to ask a quick question regarding Carbon...

Should I avoid it like the plague, or is it still necessary to use it ever?

I'm just learning to use a 3D graphics engine (Ogre 3D) which appears to work much better with Carbon than Cocoa (cocoa will end up having artifacting for some reason where Carbon won't,) but ultimately I'd like the game I'm making with it to be sold on the Mac App Store.

So... Figure out how to make it work with Cocoa, or should I just accept the easy solution of using Carbon?
Carbon is not the "easy solution", because you will have to throw all your Carbon code out and replace it with Cocoa quite soon. Carbon is 32 bit only. It is not actively developed, which means known bugs will not be fixed. It is deprecated. I was told that you can't update your development machine to Mountain Lion.


Quote:
Originally Posted by throAU View Post
Carbon is deprecated - don't think Mountain Lion will run it?
It will still be able to run Carbon apps, but you can't develop Carbon apps on Mountain Lion. Which seems a very good indication that in 10.9 Carbon may be completely gone.

Last edited by gnasher729; May 1, 2012 at 07:57 AM.
gnasher729 is offline   0 Reply With Quote
Old May 1, 2012, 09:45 AM   #16
ArtOfWarfare
macrumors 603
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
Quote:
Originally Posted by gnasher729 View Post
Carbon is not the "easy solution", because you will have to throw all your Carbon code out and replace it with Cocoa quite soon. Carbon is 32 bit only. It is not actively developed, which means known bugs will not be fixed. It is deprecated. I was told that you can't update your development machine to Mountain Lion.
By "easy solution", I just meant the one that required no effort right now on my part. But, message received, stop using carbon immediately. Transition period is over; now isn't the time to be holding onto it.

I guess I need to figure out why the engine has artifacting under cocoa and fix that... doesn't sound like a fun task... not even one I know where to begin with fixing.
__________________
Don't tell me Macs don't last: 2007 iMac, 2007 Mac Mini, 2008 MacBook Air, all Vintage.
(iMac obsoletion: April 28, 2015, MBA: October 14, 2015, Mac Mini: March 9, 2016)
ArtOfWarfare is offline   0 Reply With Quote
Old May 1, 2012, 09:59 AM   #17
chown33
macrumors 603
 
Join Date: Aug 2009
Quote:
Originally Posted by ArtOfWarfare View Post
I guess I need to figure out why the engine has artifacting under cocoa and fix that... doesn't sound like a fun task... not even one I know where to begin with fixing.
Does Ogre 3D have a home page? Maybe there's a newer version.

If there's not a newer version, is there a bug-report web page? Have you filed a bug there?
chown33 is offline   0 Reply With Quote
Old May 2, 2012, 12:16 AM   #18
Sydde
macrumors 68000
 
Sydde's Avatar
 
Join Date: Aug 2009
Quote:
Originally Posted by chown33 View Post
Does Ogre 3D have a home page? Maybe there's a newer version.

If there's not a newer version, is there a bug-report web page? Have you filed a bug there?
http://www.ogre3d.org/

perhaps? It looks like it is meant to be a cross-platform API layer.
__________________
You got to be a spirit. You can't be no ghost.
Sydde is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Carbon Skin? Ncage1974 MacBook Pro 2 Feb 28, 2014 05:51 PM
Bodyguardz carbon fiber skin vs. Ghost Armor Carbon fiber skin estestyler26 iPhone Accessories 4 May 7, 2013 09:18 PM
Carbon Skin? Ncage1974 MacBook Air 7 Mar 12, 2013 12:41 AM
Help with my first Cocoa App eugiel Mac Programming 1 Sep 30, 2012 08:18 AM

Forum Jump

All times are GMT -5. The time now is 07:43 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC