Re: ObjC++ (and a word about Java, too ;-)
Re: ObjC++ (and a word about Java, too ;-)
- Subject: Re: ObjC++ (and a word about Java, too ;-)
- From: Mark Eaton <email@hidden>
- Date: Wed, 5 Dec 2001 16:16:33 -0800
On Wednesday, December 5, 2001, at 08:32 AM, Thomas Lachand-Robert wrote:
Le mercredi 5 dicembre 2001, ` 04:25 , Eric Schlegel a icrit :
Obviously that's just an opinion, but every time I have to look to the
documentation of Carbon, I'm scared. All these strange names FSSpec,
FSRef,
kXooopsArgh, etc. I did use it some weeks ago because I needed to
acces type/creator information, and I got an headache just for this
simple thing.
My code came as follows (probably not the best, but I basically copied
somewhere in the doc):
OSStatus status;
FSRef fsRef;
const char* cname;
FSSpec fsSpec;
FInfo fndrInfo;
cname = [[fullPath stringByExpandingTildeInPath] UTF8String];
status = FSPathMakeRef ((UInt8*) cname, &fsRef, NULL);
if (status == 0)
status = FSGetCatalogInfo (&fsRef, 0, NULL, NULL, &fsSpec, NULL);
if (status == 0)
status = FSpGetFInfo (&fsSpec, &fndrInfo);
if (status == 0) {
macType = fndrInfo.fdType;
macCreator = fndrInfo.fdCreator;
}
It is very difficult to understand what happens. Compare with a similar
piece in Cocoa:
NSDictionary *fattrs = [file attributes];
NSDate* date = [fattrs objectForKey:NSFileModificationDate];
NSString *group = [fattrs objectForKey:NSFileGroupOwnerAccountName];
NSString *owner = [fattrs objectForKey:NSFileOwnerAccountName];
Exception removes the need of "status", classes and dictionaries don't
need strange names, etc.
Also the organization as a whole is very difficult to understand, even
for me, who has commit a few programs on the plain old mac toolbox (ok,
it was some years ago). The comparison with Cocoa, whose structure is
very simple (there is only a small number of classes, as Ondra likes to
emphasize), is not to the glory of Carbon. It is obvious to me that a
new programmer on the mac should learn Cocoa, not Carbon.
You're confused on two fronts:
1) The vast majority of (and I mean almost all) Carbon programmers are
insulated from the Toolbox by a framework. Sample code for how to get
the type and creator of a file using the PowerPlant framework (for
instance) will be 2-3 lines long. In fact, the raw Carbon example
consisted of 3 function calls. You seem to be getting hung up on
function and argument names more than anything else.
2) Lack of familiarity does not make something inferior.
Having said all that rest assured that Mac OS X will whither quickly
without Carbon (about as fast as Rhapsody did).