Learning Objective-C on the Macintosh
There'll be one more programming book on the Macintosh aisle market in the next few weeks, by Mark Dalrymple and Scott Knaster: Learn Objective-C on the Macintosh.
If you've never heard of these guys, Mark often hangs out teaching at the Big Nerd Ranch, which is famous for (among other things) teaching Apple's software engineers to use Cocoa, and co-authored Core Mac OS X and Unix Programming and Advanced Mac OS X Programming with Aaron Hillegass, both of which I own but really only take off the shelf when I've been feeling too smart that day and need to drop it down a notch...
Scott Knaster has been all over the map, from working as an upper-up in the support levels at Apple, to a bunch of coding books for the Mac, to currently working at Google. I started stalking him after purchasing Hacking Mac OS X Tiger, which I primarily picked up because Rentzsch's mach_star was profiled towards the end. If you've been around awhile, you may have seen it in the sidebar for quite awhile.
It was such a deliciously weird book, which was just all over the map and in some cases didn't make a whole lot of sense, but not in a bad way -- it's just that there was such a juxtaposition between skill levels and content. We're talking starting on how to clone and screw around with Dashboard widgets or iPhoto and ending with mach_star insanity.
If someone knew how to mess around with mach_star, it wasn't as though they'd have a lot of problems glossing through the Apple docs and figuring out some of the other things themselves, but the right way to look at it was that someone picking up the book looking for little mini things to hack about in would then get this crash course that things like mach_star existed. I was charmed.
I want to be clear here so that people aren't getting the idea, because the reason why I started stalking Scott to pass on kudos wasn't really so much that there was this somewhat absurd juxtaposition in the content, but rather that it ended up working as a cohesive whole. I fail at this often enough that when I see someone else pull it off it snags my radar in a big way, as it's not like I track down everyone just to pass on a Thumbs Up.
I love Mac-specific books, even if I don't always like a lot of the specific tomes which seem to just get churned out around different applications. You could pick up any-old book of C, fire up XCode and get to town, but something up to date and Mac-specific can seriously alleviate a lot of headaches for a beginning programmer, the quickest examples coming to mind being how to actually use the IDE.
There are a decent amount of programming books out there for the Mac, but there aren't all that many. I'm told one of the major reasons for the death of the O'Reilly OS X conference was that they were disappointed that book sales for the platform weren't meeting internal expectations, but they still have a lot of good content out there even if they got off to a rough start (Let's just say their first Cocoa book didn't get 4 stars around the web), and other publishers have jumped in with cool tomes.
There wasn't always such a yummy selection from multiple publishers, and there are still cases publishers are deciding it's just not worth their while. There are some weird things about whipping up a programming book for the Mac, a few of which come immediately to mind:
- The OS was such a moving target, with updates coming so frequently, that by the time your book was published, chances are a good chunk of it would be out of date. In many cases these things would be minor (like screenshots of the XCode looking out of date) and in many cases they'd be severely annoying or just plain wrong.
- Windows is the great homogenization, and all other platforms skew. The userbase of the Mac and other alternative platforms skews depending upon where they excel, as to put it bluntly you don't buy a Mac if gaming is high on your priorities list, but you may well if other things are that the Mac handles aptly. While the number of technically-minded users has grown vastly since the OS9 days, the base still skews away from them.
- Google can be such a bitch for a publisher trying to collate information and then getting you to pick it up within a paper medium. It doesn't entirely obsolete it, but being able to quickly google on a problem you're hitting or a technical detail is a nightmare for a technical tome.
They aren't necessarily exclusive to the Mac as a platform, and doesn't include the larger one coming to mind -- just plain numbers. As an example, say you want to write a programming book for the Macintosh, one of the first things you have to do is figure out where you are going to put the cut-off point and how your actual book will skew, as you have to decide what you are going to expect a user to already know.
If it's a Cocoa book, the publisher isn't going to really want you to teach someone how to program C, and then Objective-C, and then Cocoa, and then hit advanced topics -- they've run the numbers on how many copies they expect to be able to sell, that's just too many dead trees, and by the time you shipped it a sizable chunk of the content would need updating.
So you may decide you're going to assume they know nothing, and drop them into C and bring them up to a smattering of Cocoa, or you may decide you're going to assume they know C++ from other platforms and go light on the Obj-C syntax and focus primarily on how Cocoa's paradigms and APIs work, because syntax is only part of the equation.
Unfortunately, if the route you're taking makes any kind of sense, chances are competing publishers are taking an extremely similar tack, so what market there will be split several ways. E-books help one lower publishing costs to better carve out that niche, but this is rough on every platform and just exacerbated a bit on the Mac. Plus, you always have to factor in that publishing companies are fucking crazy.
I really hate talking about a book I can't actually see and use and then really comment on because it hasn't actually shipped yet, but the above should give you an idea as to why I'm grooving that it will be shipping.
That said, I pinged Scott a bit to clarify a few tibits I was confused about:
- You should expect to have some programming knowledge going into this book, as it won't be necessarily teaching you how to program C. I'm told they do quite a bit of hand-holding, so if you bought a book on C but only made it part-way through you should be fine. If you have spent any time in Java, you should be fine.
- There's a superhero on the cover because the credits actually read: "Pencilled by Mark Dalrymple, Inked by Scott Knaster." The guy on the cover came about because Mark wrote the text and Scott polished and clarified it. Your superfluous trivia nugget of the day is that he's called "Bracket-Man."
If you're interested, you can sign up at the top right to be notified of when it's shipping, and they generally have a free chapter to download once it's released for purchase either as a tome or an e-book.
Comments (17)
Posted by: stinksoup at January 20, 2006 01:47 PM
"...so if you bought a book on C but only made it part-way through you should be fine."
Heh. Things get hazy after the pointers chapter, usually.
Posted by: Elfred Pagan at January 20, 2006 02:22 PM
Bryan,
For C, you can always count on "The C Programming Language" by K&R. It's one of those classic programming books that everyone should read. Then, you might want to pick up "Cocoa Programming for Mac OS X" by Aaron Hillegass, this will take you through Cocoa and XCode.
Elfred
Posted by: virgil pfutzenrueter at January 20, 2006 03:40 PM
"... publishers are taking an extremely similar tact, ..."
the word you are looking for there is "tack." it's a sailing term.
Posted by: Jake at January 20, 2006 04:22 PM
so what if all I've ever done is basic programming on an Apple II (and "advanced basic" LOL on a TI-99/4A)? is there any book out there that's a good introduction to programming in Cocoa? or should I give up and let the professionals do that job? =]
Posted by: Zetetic at January 20, 2006 04:43 PM
Tried to get comfortable with C to learn Objective-C with Cocoa...
Thank goodness for RubyCocoa. Just like VisualBasic but nice... [;)]
Posted by: Stripes at January 20, 2006 06:28 PM
so what if all I've ever done is basic programming on an Apple II (and "advanced basic" LOL on a TI-99/4A)
I want to say "get a book on PyObjC, or RubyCocoa, or F-Script", but I don't think there are any. Worse yet the online docs for those languages seem to assume you know the Cocoa ObjC APIs and tell you how to translate to PyObjC/whatever in your head. So they are not ideal learning environments.
They do have some advantages over straight Cocoa though, no resource leaks, and no using an object after it is freed (both of which are hard to track down bugs).
To learn Cocoa without knowing C, I would get a decent C book (I learned from the K&R one, but I think it is a bit of an abrupt into to lowish level languages!). Skim it, you will need to know how to use pointers, but you won't really need to know pointer math. You will need to know a little about malloc and free, but not much since ObjC replaces them with the somewhat-easier to use "retain/release/autorelease".
Then I would get Aaron Hillegass' Cocoa Programming for Mac(R) OS X. I've attempted Cocoa a few times, and it is the best of the 3 books I've used. I actually used the 1st edition, but expect the 2nd is at least as good. I haven't finished the book (time constraints), but unlike the other books, I'll pick this one back up when I get some slack time.
If you try the C book, and really just can't get into it, give PyObjC or CamelBones, F-Script, or RubyCocoa a shot. All of those languages take care of signifigantly more of the low level details for you, and make it hard to make whole classes of mistakes. If someone did a good "Cocoa using (any of those languages)" book, it would be a great intro.
Posted by: Bryan at January 20, 2006 11:57 PM
Elfred and Stripes,
thanks for your advice
Bryan
Posted by: James Ramsey at January 21, 2006 12:45 AM
The following link is to the cocoa tutorials page of the O'Reilly mac dev center. If you scroll to the very bottom of the list, and start working your way up, it's the best intro that I've ever found.
I still use the color meter I "wrote" in lesson 6 from time to time... They are old, and some of them need to be brought up to date, but they should be decipherable, and they just seemed to present things in a manner which worked with my learning processes.
Enjoy
http://www.macdevcenter.com/pub/ct/37
Posted by: rexbinary at January 21, 2006 01:42 AM
I've had my eye on several books from SpiderWorks for quite awhile.
Problem is I work on a PowerBook G4 12-inch, so flipping back and forth between Xcode and a PDF document was just not practical.
I emailed them about making print versions and I'm glad they are finally doing it!
Posted by: Roy J Stark Jr. at January 21, 2006 10:48 AM
love the Cow!!!!
keep it up.
Posted by: has at January 21, 2006 11:30 AM
Bryan,
Couple of thoughts from another self-taught programmer...
While learning languages and frameworks it's a good idea to do some reading on the theory side as well. Learning the tools is only half the challenge; you also need to learn how to think like a programmer. Otherwise it's a bit like understanding what all the controls in a car do without knowing the highway code, or techniques for parallel parking and three-point turns, or when to hit the brakes so you stop in time. Cocoa's great technology but learning to think the Cocoa way isn't trivial, and you really need to be familiar with concepts and techniques like abstraction, inversion of control, object-oriented design and event-driven programming to use it effectively.
Consider starting off in a high-level scripting language - I'd recommend Python or Ruby - and get comfortable with using basic language features like values, variables, flow control and functions by writing straightforward GUI-less batch processing scripts. There are plenty dead-tree and online tutorials to teach these languages, so start with one of those. While you're doing this, pick up a high school-level computing studies textbook and skim through that to fill in some basic background knowledge.
Once you've got the basics under your belt, grab yourself a copy of Code Complete to learn more advanced concepts and practical programming techniques, and a nice Cocoa book for learning the frameworks. Python and Ruby both have extensive Cocoa bindings, so it is possible to learn Cocoa programming with only a passing knowledge of C (mostly to understand the tutorials and examples, most of which use ObjC). Or do a bit of object-oriented programming in Python or Ruby, and get yourself a C book and learn C properly; the ObjC extensions to C are trivial to pick up from there.
...
Alternatively, if your interest is in writing neat little GUI apps that aren't too complex and aren't really interested in the 'real programming' side of things, consider investing in a non-programmer oriented environment like Runtime Revolution or maybe RealBasic. Those don't require as much background knowledge to use, allow you to hack stuff out pretty quickly, and are much more forgiving when you make mistakes.
HTH
Posted by: Jon H at January 21, 2006 09:48 PM
Another new book is "Programming with Quartz: 2D and PDF Graphics in Mac OS X" by David Gelphman and Bunny Laden.
Not Cocoa, but scrumtious.
Posted by: rentzsch at January 22, 2006 03:12 PM
"Pencilled by Mark Dalrymple, Inked by Scott Knaster."
Crap. Dalrymple can draw, too? I'm falling behind the curve. I bet he keeps his keyboard on the floor, typing in-between each push-up.
Posted by: Abhi Beckert at January 22, 2006 04:11 PM
I'm an admin at a forum, and we allways get people asking for the best cocoa book. Lately I've found it hard to recomend anything, you really need a book that covers bindings and core data. Any new app should use both extensively, and neither is a simple topic.
Great to see there's finally a new book coming out, I probably won't buy it, but I'll be recomending it.
Posted by: Chris Forsythe at January 22, 2006 07:55 PM
This is the doc I've been making with just notes along the way
Posted by: robcast at January 23, 2006 09:36 AM
Completely OT: The better BASIC on the TI99/4 was called "Extended Basic" and it was the first BASIC I met (in 1983) that had subroutines with local variables (but no recursive calling of subroutines).
That's what I spent a lot of time with at the time...








For someone with no programming experience, what books would you recommend for learning C, Objective C and Cocoa?