views:

339

answers:

1

I'm looking for strategies and articles on making Carbon code 64-bit ready.

Carbon for 64-bit does not and will not exist. It's pretty much a dead end.

So in order to bring Carbon application and toolkits to 64-bit their GUI part will have to be re-written in Cocoa and Objective-C, right?

How can I minimize the effort I have to put into the transition? How can I minimize the amount of needed Objective-C code?

+1  A: 

So in order to bring Carbon application and toolkits to 64-bit their GUI part will have to be re-written in Cocoa and Objective-C, right?

Yup.

How can I minimize the effort I have to put into the transition? How can I minimize the amount of needed Objective-C code?

  1. Learn Cocoa. Read The Objective-C Programming Language and the Cocoa Fundamentals Guide. Become familiar with MVC, KVC, and Objective-C. Bookmark the Foundation and AppKit framework references. Learn to love Interface Builder, for it is your friend (moreso in Cocoa than it ever was in Carbon).
  2. Get good at Cocoa. Read more Guides (if you're still on Leopard, use [1] instead). Write as many throwaway apps and even real apps as you can get away with in whatever time you have available. If you can, give them away under a BSD license, and write reusable source code and give that away, too. People will find bugs and some will tell you about them, and some will submit patches. Get to be able to write a complete app with a model layer, no more than two controllers, and at least one custom view or cell in a day.
  3. Read the Carbon Porting Guide, then port your app.

I came from Carbon myself. It's completely different—you may as well start fresh, ignoring your previous Carbon experience, and maybe you won't make some of the early mistakes I did (like skipping the model layer).

As for your app, you probably have a lot of surgery to do, as Carbon did not force you to keep UI and logic separate like Cocoa does. Cocoa enforces MVC; if you don't adhere to it, you pay the price by reinventing wheels and making and correcting mistakes.

That makes Cocoa sound like more work, but it's not. Porting is hard (inevitably), but otherwise, Cocoa is quite the opposite: Writing (and reading!) a Cocoa app is much easier than writing (and reading) a Carbon app. Once the porting is over, you'll be glad you switched.

Oh, and many people will recommend one or both of Cocoa Programming for Mac OS X by Aaron Hillegass and Programming in Objective-C 2.0 by Stephen Kochan. I have the first book, and have read some of it, but that was after I had already learned Cocoa, so I can't earnestly recommend it; that said, it is not bad, and I don't think you'd do wrong to read it. I have not even seen the second book, so I won't say anything about its quality.

[1]: file:///Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.CoreReference.docset/Contents/Resources/Documents/documentation/Cocoa/index-date0.html (Stack Overflow won't let me link file: URLs)

Peter Hosey
I am actually more familiar with Cocoa than with Carbon, but I use code/libraries (not written by me) that's build on Carbon (FLTK, OpenCV,...). So I don't want to spend much time on understanding Carbon. I was looking for a porting guide at Apple's site, but could not find one. The "Carbon Porting Guide" you refer to is about porting legacy apps from Mac OS 9 TO Carbon, not Carbon to Cocoa.
f3lix
Oh, OK. Well, FLTK will probably have to go unless you want to port it (assuming it's open source). OpenCV doesn't appear to be Carbon-based, just C-based, so it should work just fine. You call it a “Carbon app”, so I'm assuming that you already have a Carbon-based implementation, perhaps inherited from previous developers. If you want to port the existing code and not simply write a new app from the ground up, you're going to have to understand at least basic Carbon. Try Getting Started with Carbon: http://developer.apple.com/legacy/mac/library/referencelibrary/GettingStarted/GS_Carbon/
Peter Hosey