Skip navigation.
 
mlRe: Guidance for Cocoa's steep learning curve
FROM : David Wilson
DATE : Thu May 15 07:16:04 2008

On Wed, May 14, 2008 at 11:33 PM, Scott Ribe <<email_removed>> wrote:
>>> === If you are primarily an experienced C++ programmer (In my
>>> experience you will have the hardest time)

>>
>>
>> (2) I will have to personally disagree with this.

>
> I wonder, seriously, if it doesn't depend somewhat on whether or not you're
> a really good C++ programmer...
>


I'd say it depends more on the type of C++ programming you're coming
from. If you're coming from a purely procedural background with no
event-driven experience, some pretty fundamental Coca concepts are
going to be problematic. If you're comfortable with C++ strict typing
rules, Objective-C may appear to have too much runtime magic going on.
On the other hand, if you've spent a lot of time abusing void * to
hack runtime dynamism into C++, Objective-C will be a breath of fresh
air ("You mean I can do this with sane syntax rather than lots of
casts and abuses of types?"). Also, memory management may throw you
for a loop if you haven't seen reference counting before; if you've
implemented it in C++ out of frustration, however, it's quite clear.

When I was first learning Cocoa and Objective-C, coming from more of a
systems programming background, what made sense of it was to
understand the runtime itself- and there is documentation on it- so
that things ceased to be "black boxes" and I could trace program
control flow without gaps. Once it's clear that methods are just
virtual functions with a different syntax and the ability to actually
determine whether or not they exist at runtime rather than crash,
objective-c is identical to c++ object oriented programming (okay, for
loose definitions of "identical", I don't want to get into the
details; given that insight there are clear broad similarities in
implementation).

So, from a C++ perspective, I'd offer the following points:

1) The type "id" is just void *, except the compiler doesn't complain
when you don't cast it to something real before calling functions on
it as an object.
2) Method calls are just calls to virtual functions, with a little
more runtime support to make them less fragile. In effect,
*everything* in Objective-C is a virtual function; you can't have
non-virtual functions.
3) Instance methods (with the -) are virtual functions. Class methods
(with the +) are static functions.
4) Outlets are just pointers. When your nib gets instantiated with
your object as File's Owner, your outlets (just member variable
pointers) have their values set to point to the things you told them
to point to in the nib.
5) Target-Action setup is just a pointer to an object + a function
pointer. You're telling something "Hey, when X happens, call this
function on this object." Think of callback functions.

There are others, but those are the most basic. Once you can map the
Objective-C constructs onto what's happening under the hood, it
becomes more clear how to take advantage of them.

--
- David T. Wilson
david.t.<email_removed>

Related mailsAuthorDate
mlGuidance for Cocoa's steep learning curve Erik Buck May 15, 03:19
mlRe: Guidance for Cocoa's steep learning curve Ricky Sharp May 15, 04:26
mlRe: Guidance for Cocoa's steep learning curve Scott Ribe May 15, 05:33
mlRe: Guidance for Cocoa's steep learning curve David Wilson May 15, 07:16
mlRe: Guidance for Cocoa's steep learning curve Jens Alfke May 15, 16:59
mlRe: Guidance for Cocoa's steep learning curve Scott Ribe May 15, 17:18
mlRe: Guidance for Cocoa's steep learning curve colo May 15, 17:21
mlRe: Guidance for Cocoa's steep learning curve Uli Kusterer May 15, 17:54
mlRe: Guidance for Cocoa's steep learning curve colo May 15, 18:03
mlRe: Guidance for Cocoa's steep learning curve Jens Alfke May 15, 21:06
mlRe: Guidance for Cocoa's steep learning curve Stefan Werner May 15, 21:17
mlRe: Guidance for Cocoa's steep learning curve Scott Ribe May 15, 21:53
mlRe: Guidance for Cocoa's steep learning curve Bruno Sanz Marino May 16, 00:39
mlRe: Guidance for Cocoa's steep learning curve mmalc crawford May 16, 02:03
mlRe: Guidance for Cocoa's steep learning curve Jens Alfke May 16, 03:06
mlRe: Guidance for Cocoa's steep learning curve Joseph Ayers May 16, 03:33
mlRe: Guidance for Cocoa's steep learning curve Jens Alfke May 16, 04:07
mlRe: Guidance for Cocoa's steep learning curve mmalc crawford May 16, 06:12
mlRe: Guidance for Cocoa's steep learning curve James Merkel May 16, 07:04
mlRe: Guidance for Cocoa's steep learning curve John Terranova May 16, 07:32
mlRe: Guidance for Cocoa's steep learning curve Ilan Volow May 16, 08:55
mlRE: Guidance for Cocoa's steep learning curve john darnell May 16, 15:30
mlRe: Guidance for Cocoa's steep learning curve Michael Ash May 16, 15:49
mlRe: Guidance for Cocoa's steep learning curve I. Savant May 16, 15:57
mlRE: Guidance for Cocoa's steep learning curve john darnell May 16, 16:19
mlRe: Guidance for Cocoa's steep learning curve I. Savant May 16, 16:27
mlRe: Guidance for Cocoa's steep learning curve Jeff LaMarche May 16, 16:29
mlRe: Guidance for Cocoa's steep learning curve Michael Ash May 16, 16:31
mlRe: Guidance for Cocoa's steep learning curve Jens Alfke May 16, 16:50
mlRE: Guidance for Cocoa's steep learning curve john darnell May 16, 16:57
mlRe: Guidance for Cocoa's steep learning curve I. Savant May 16, 17:04
mlRe: Guidance for Cocoa's steep learning curve Michael Vannorsdel May 16, 17:41
mlRe: Guidance for Cocoa's steep learning curve Andy Lee May 16, 20:05
mlRe: Guidance for Cocoa's steep learning curve Scott Ribe May 16, 20:22
mlRe: Guidance for Cocoa's steep learning curve Shawn Erickson May 16, 21:51
mlRe: Guidance for Cocoa's steep learning curve Michael Ash May 17, 08:56
mlRe: Guidance for Cocoa's steep learning curve Torsten Curdt May 17, 11:53
mlRe: Guidance for Cocoa's steep learning curve Michael Ash May 17, 12:02
mlRe: Guidance for Cocoa's steep learning curve Torsten Curdt May 17, 12:46
mlRE: Guidance for Cocoa's steep learning curve john darnell May 19, 15:26
mlRe: Guidance for Cocoa's steep learning curve David Casseres May 22, 05:59
mlRe: Guidance for Cocoa's steep learning curve David Casseres May 22, 06:12