Programming in Objective-C

This post was published more than a few years ago (on 2004-08-08) and may contain inaccurate technical information, outmoded thoughts, or cringe takes. Proceed at your own risk.

Programming in Objective-CWell, after spending some more time looking for the rest of that "C is for Cocoa" series which doesn't seem to yet exist, and on the basis of several reviews and comments in forums, I bought the book Programming in Objective-C by Stephen G. Kochan. Yes, I want to learn programming in Cocoa, but as Objective-C is the lingua optimus for programming with Cocoa, it seemed like the logical first step. (You can also program with Cocoa in Java, but it's not recommended.) On top of that, I'm finding that there are other environments like Cocoa that exist on other platforms like NeXTSTEP (its predecessor) and open-source variants like gnuSTEP and LinuxSTEP, which means that when the time comes, if I know how to write a solid program in Objective-C, I may, in fact, be able to port it to Windows and Linux without serious wailing and gnashing of teeth.

A bit from the author's introduction neatly sums up exactly why this book was the one:

When contemplating writing a tutorial on Objective-C, a fundamental decision had to be made. As with all prior texts on Objective-C, I could write mine to assume the reader already knew how to write C programs. I could also teach the language from the perspective of using the rich library of routines, such as the Foundation and Application Kit frameworks. Some texts also take the approach of teaching how to use the development tools, like the Mac's Project Builder and Interface Builder.

I had several problems adopting this approach. First, learning the entire C language before learning Objective-C is wrong. C is a procedural language containing many features that are not necessary for programming in Objective-C, especially at the novice level. In fact, resorting to some of these features goes against the grain of adhering to a good object-oriented programming methodology. It's also not a good idea to teach all the details of a procedural language before learning an object-oriented one. This starts the programmer off in the wrong direction, and gives the wrong orientation and mindset for fostering a good object-oriented programming style. Just because Objective-C is an extension of the C language doesn't mean you have to learn C first!

So, I decided neither to teach C first nor to assume prior knowledge of the language. Instead, I decided to take the unconventional approach of teaching Objective-C and the underlying C language as a single integrated language, and from an object-oriented programming perspective. The purpose of this book is as its name implies: to teach you how to program in Objective-C. It makes few assumptions about the platform you're running under, the development tools you have available, or the library of classes at your disposal. All that material can be learned elsewhere, after you've learned how to write programs in Objective-C. In fact, mastering that material will be much easier after you have a solid foundation on how to program in Objective-C. This book does not assume much, if any, previous programming experience. In fact, if you're a novice programmer, you should be able to learn Objective-C as your first programming language from this text.

A little wordy and repetitive, yes, but that may be a plus when it comes to an instructive text, and it's exactly what I needed to hear after picking up several books that--- because they assumed I already knew C--- were next to useless.