How much is "some" in C programming?
May 31, 2009 6:45 AM   Subscribe

How much of C do I need to learn before moving on to Cocoa, and what's the best resource for learning it?

I'm very interested in programming for the Mac and iPhone, but I have no real prior programming experience. On the recommendation of an AskMeFi answer, I bought the latest edition of the Hillegass book. However, it states something like "this book was written for those who already know some C programming and something about objects." So how much is "some"? What resources will best help me learn the parts of C I need to know before moving on to Cocoa? I want to hit the ground running, so if there is a good crash course out there, what is it?Are there any video resources?
posted by joshrholloway to Computers & Internet (18 answers total) 18 users marked this as a favorite
 
Have you tried the examples in the Hillegass book? It's been years since I learned C, and I learned it in a classroom setting, but I program some Objective C (mostly Java, but some Obj C) these days, and it seems like all you really need from C is the basic syntax of the language. Depending on your aptitude, you may be able to pick up what you need by thinking over Hilegass's examples. In terms of references, I haven't read either of these, but I've had generally good experience with O'Reilly books: Practical C Programming, or for a more concise overview, C in a Nutshell.

Since you're dealing with object-oriented programming, it might not hurt you to look at a Design Patterns book, either. The canonical example is Design Patterns by the "Gang of Four," but there are more accessible options out there. A friend of mine who bootstrapped herself from C to Java last year swears by "Head-First Design Patterns for Java," but since you don't have an interest in Java, that probably isn't the best solution for you.
posted by Alterscape at 7:02 AM on May 31, 2009


I liked Dave Mark's Learn C on the Mac, which is specifically geared towards people who want to immediately move on to Objective C / Cocoa projects.
posted by bcwinters at 7:08 AM on May 31, 2009


(I should note that Learn C on the Mac has had many editions over the years, and the older editions—which probably predate OS X—are going to be completely useless for your purposes. So be cautious if you buy a used copy, sight unseen.)
posted by bcwinters at 7:11 AM on May 31, 2009


I'd start with plain C, move on to Objective C and finally to Cocoa touch.

For C, you need to understand at least the syntax and general programming concepts.

For Objective C, you need to grasp the Object Oriented Programming aspects and understand how classes and Objects work. Then you can move on to Cocoa Touch.


There's lots of resources, bot free, online, and books. Here's some stuff for Objective C.
This first one is Apple's guide:

http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Introduction/introObjectiveC.html


And this free ebook was of great help for me:
http://www.otierney.net/objective-c.html
posted by spacefire at 8:35 AM on May 31, 2009


Is this a hobby pursuit, or a career change? How much investment are you willing / able to put in to this? What timeframe are you thinking?
I ask, because if you really want to both become a programmer, and forge a career in Cocoa / iPhone developing, that's one trajectory. If instead, you'd just like to "poke around and have fun," that's an entirely different trajectory.
In the former case, I'd seriously think about taking a crash course at the Big Nerd Ranch (but make sure to ask them what kind of preparation you'd want to do). In the latter case, why not just fire up XCode with some sample apps from the Interwebs (Apple's Developer Center is very good, and free), and demand-fetch in stuff from books or Google when it doesn't make sense.
posted by dylanjames at 9:06 AM on May 31, 2009


Since nobody mentioned it so far, I'm going to be That Guy and suggest you pick up a copy of Kernighan and Ritchie.

It may not be closely aligned to your immediate interests, but it's not such a big book and is a real classic. Having a solid understanding of C is an excellent investment that is bound to pay off in the long term.

The catch is that you really need to do the exercises to get the most out of it, so it may fail your "hit the ground running" requirement.
posted by Dr Dracator at 9:50 AM on May 31, 2009 [1 favorite]


I'd skip the K&R and go to C-99.

K&R is ye Olde Englishe compared to the modern dialect, and has some curliques that are no longer relevant, especially for Objective-C.

Note that iPhone programming can be superset of C++ programming -- if your source files end in .mm they will be compiled as C++.

C++ is a bag of pain the deeper you go down its rabbit hole but has syntactical sugar that I find useful.

iPhone programming doesn't need the real difficult parts of C or C++ (ie involved pointer-based techniques or the C++ Standard Library) since we use Foundation collection classes to assemble the data model now.

I'd say once you know what each C keyword does you can start getting your feet wet in Objective-C. 90% of your program will be dealing with Foundation.

Objective-C 2.0 features -- eg. "properties" which are used heavily by the iPhone APIs -- are rather tacked-on and kludgey compared to Java and C#, but learnable.

Just remember to start small and do iterative development. Learn the Foundation Kit classes inside and out. It is the best part of OS X / iPhone programming.
posted by @troy at 10:06 AM on May 31, 2009


It depends on how many languages you've already done in the past. Java, php, stuff like that? Even Visual Basic would be fine... If you have, I'd suggest Hillegass Cocoa programming for the Mac (already mentioned above), and Learn Objective-C on the Mac by Dalrymple and Knaster, and "Beginning iPhone Development" by Mark LaMarche.

I worked myself through all three of them pretty quickly because I could skip most of the concepts (like object-orientation and all that comes with it), and could concentrate on what was different from what I already knew - you will need more time with these books if you've got less experience with other languages, but they're a great place to get started if you at least have some programming background, even if it isn't in C, so that's why I asked about non-C stuff.

If you have no programming experience at all, it's a different story, and I'd recommend working on that first. I've been too long in the industry to recommend books in that case, sorry.

Start off with the "learn objective-C on the mac" book, since it deals with the language and object orientation, and from that work through the cocoa book to get you started on the user interface concepts on the Mac OS (which is very similar to iPhone, as you may already know). Save the iPhone book for last.

Last time I had programmed for the Mac was back when System 7 was the hot thing, and I did a lot of web based stuff before I got back to the Mac and iPhone. That was in march, and I've since released to the app store since then. Here what I managed to do...
posted by DreamerFi at 10:31 AM on May 31, 2009


Response by poster: Is this a hobby pursuit, or a career change?

Definitely not a career change right now, but maybe eventually. However, I hope to be proficient enough before long that my current employer might want to use some of my skills in this area.

In the former case, I'd seriously think about taking a crash course at the Big Nerd Ranch...

I have looked at these classes, but the distance and cost is very prohibitive for me. However, I have looked at taking a few courses in C at a local community college. Would this be a good start?
posted by joshrholloway at 10:54 AM on May 31, 2009


I've been doing self-study in Objective-C using Programming In Objective-C 2.0, which is written expressly to move the programming novice into Obj-C without having to do prior study in C first. I haven't tried to program since the C-64 was fashionable, so it's been a bit of a slog, but it seems to be a well-written book which will allow you to sidestep the C prereq.

Coupled with the Stanford iPhone programming course which is posted on iTunes (link requires iTunes), I'm hoping to make some good forward progress with learning this topic.
posted by hippybear at 11:08 AM on May 31, 2009 [1 favorite]


(I should also mention I got O'Reilly's iPhone SDK Application Development as an additional text. O'Reilly rocks.)
posted by hippybear at 11:28 AM on May 31, 2009


Dave Mark's "Learn C on the Mac" is excellent and you learn XCode at the same time.
posted by neuron at 12:08 PM on May 31, 2009


Picking up the differences between K&R 2nd C and C99 is trivial.

Every badass engineer I know has a copy of K&R. I have a copy of K&R. You should get a copy of K&R (2nd edition). Once you've finished it and really understand it, no other halfway decent documentation will challenge you. (Chapter 5 is also going to guarantee that you understand pointers.) In fact, K&R is so well-written that you will probably laugh at most other "learn xyz books" because of the poor, convoluted way so many of them are written.

As far as Obj-C goes, the ADC documentation on the language is good and clear. Many people swear by the Kochan book mentioned by hippybear. The Hillegass book on Cocoa is excellent and no new Cocoa programmer should be without it.

I have looked at taking a few courses in C at a local community college. Would this be a good start?

It certainly won't hurt, assuming the instructor is good.
posted by secret about box at 2:08 PM on May 31, 2009 [1 favorite]


K&R is old, but it is so well-written (and concise) that it beats off the pants of the other books. Learning C-99 and ObjC is trivial after learning K&R. Skipping K&R is like trying to build a house without laying down a solid foundation.
posted by flif at 2:35 PM on May 31, 2009 [1 favorite]


Based on my experiences, learning C did nothing to help me understand Objective-C and Cocoa. 'Objective-C' is a major misnomer: it's more object-oriented than even C++ could ever hope to be.

If you've absolutely no programming experience, I would actually recommend a counterintuitive idea: learn C# instead of C. I'm a total Mac geek and I'm saying this. For my job, I started on C# after six or seven years of C++ and a failed attempt at Objective-C. C# was the perfect bridge, and it made Objective-C logical for the first time. (More importantly, you don't have to burden yourself with memory management in C#.)
posted by spamguy at 7:07 AM on June 1, 2009


Based on my experiences, learning C did nothing to help me understand Objective-C and Cocoa.

- Learning C will not help you understand Cocoa.
- Learning C will teach you language fundamentals that you will need to understand as an Objective-C programmer.
- In learning Objective-C, you must learn C. It isn't necessary for everyone to learn the latter before moving onto former, just as long as one accepts that he or she will have to know it all in the end.
- I have never met anyone who went through K&R and didn't come out the other end as a better programmer. You don't have to start in that town, but it's a worthwhile visit.

If you've absolutely no programming experience, I would actually recommend a counterintuitive idea: learn C# instead of C.

If you have absolutely no programming experience, you lack the ability to validate anyone's recommendation. It's important to remember this whether you're the one recommending things or the one listening to recommendations.

The best advice I ever got was not "learn XYZ because of ABC", it was "start here because I can help you". Find a mentor who can help you formulate the questions you don't know you need to ask. If you don't know any Obj-C people but you know C people, start there. If your buddy is a Python kid, rock that. If you work with JavaScript people, pick that up.
posted by secret about box at 8:40 PM on June 1, 2009 [1 favorite]


hmm i appear to have digressed there for a moment, apologies for the noise
posted by secret about box at 8:40 PM on June 1, 2009


here is another long list of good books.
posted by DreamerFi at 1:34 AM on June 2, 2009


« Older Strange/Interesting Places for a Summer-long Road...   |   Help me choose a gift for a hard to buy for female... Newer »
This thread is closed to new comments.