This morning, I found myself typing strangely familiar code:
- (void) setName: (NSString *) name
{
[ name retain ];
[ name_ release ];
name_ = name; }
My first few minutes programming with Objective C were fairly painless. Surprisingly, most of my C/C++ instincts worked just fine. My really rusty COM instincts kicked in when I saw the retain (aka AddRef) and release messages. I was surprised that my C# instincts worked fine too - I was instinctively NOT typing semicolons at the end of the message sending operators (those scary looking [ … ] things in the middle of the code), which of course the compiler gently reminded me of when I tried to build my project.
However, after not programming in C++ for quite a few months, I was revulsed by the fact that I needed to have both an interface and an implementation section. And the number of keystrokes that I needed to use to get a fairly simple “Person” class up and running was also painful given the programming languages that I’ve recently been writing code in.
I’m working my way through James Duncan Davidson’s Learning Cocoa with Objective-C book that Gordon Weakliem recommended to me. It’s so much fun learning a new programming a language and set of libraries. It reminds me of the fun that I had back in May of 2000 when Don Box gave us our first drop of the CLR bits at a DevelopMentor retreat. It’s hard to believe that was almost 2.5 YEARS ago!