Re: Visualizing Cocoa
Re: Visualizing Cocoa
- Subject: Re: Visualizing Cocoa
- From: David Trevas <email@hidden>
- Date: Sun, 10 Jun 2001 09:15:49 -0500
On Sunday, June 10, 2001, at 05:35 AM, Georg Tuparev wrote:
Hmm. I still believe that the knowledge of how the runtime environments
works is essential for a good ObjC developer, and C is essential to
understand how the runtime environment is build (or can you do it
without knowing what a pointer to function is?) ... but oh well, I
might be just to old ...
Please do not misunderstand what I said about learning C. I make my
living writing C and have the utmost respect for the language. However,
there is a difference in learning C for its own sake and learning it to
move on to ObjC. I did not intend to imply that an ObjC for beginners
book would omit C features, but each feature would be given emphasis in
light of its role in Objective-C.
For example, all introductory C texts I seen start by using stdio.h
functions like printf and scanf. The Cocoa programmer has to forget
them and learn to use NSString objects. Why not learn the format codes
(%d for integer) in the context of -stringWithFormat: in the first place?
I've always had a hard time with pointers to functions and have to refer
back to the books to make sure I'm putting the stars in the right place,
but I think selectors are wonderful. Wouldn't it be easier to explain
pointers to functions in terms of selectors?
I've also heard references to using C to optimize performance. How much
faster is it to go through an array of doubles with a for() loop than to
use an NSArray with an NSEnumerator? If it is significant, arrays
should be introduced early on using NSArray and in a later chapter about
performance, the C version could be introduced. Remember, with
NSMutableArray, you get linked list functionality for free.
I'm just putting out there that it should be possible to teach an
absolute beginner how to program in Cocoa by introducing C, Objective-C
and Cocoa concepts in an intelligently blended method. I would think
Apple would be highly interested in creating such materials not only
since they would benefit the company financially, but would also enhance
Apple's prestige in the "marketplace of ideas."