views:

117

answers:

7

I've been programming PHP & mySQL for about 8 years now. I understand and make use of modern software architectures and OOP in my projects on a daily basis. I decided I want to learn something new.

I finally decided yesterday that I want to learn C and eventually Objective-C so I can begin creating Mac / iOS applications. (Would you recommend C, C# or C++? I just assumed C would be best.)

That said, I miss the days of programming BASIC tic-tac-toe games on my graphing calculator haha. I'd like to get a very good foundation in C, maybe create some command line games, and then eventually move up to GUI programming with Objective-C

Where would you recommend that I start looking online. I don't just want to understand how to make code work in C, but I also want to understand how and why code work.

Thanks & wish me luck :-)

A: 

I would recommend learning Objective-C because it's so different C. You should know most of the C-syntax developing PHP.

John Boker
Objective-C is so different from C, but PHP is similar to C? I think you're getting hung up on bracket syntax.
Chuck
@chuck the c-syntax is similar. The same control structures, for, while, if, do..while. They all share the same syntax between the languages.
John Boker
A: 

I don't really think you need to get too deep inside C, just because you usually don't need to use C code while developing in Objective-C (or at least not the features that you would learn). Start directly with Objective-C and try to fill up holes just when needed.

Although Objective-C is considered an extension of C language (in term of its grammar), it replaces almost everything you needed to do in C with Objective-C and its types, so there's no really need to use it so ofter. Usually you need it when interfacing with something low level but not so frequently (since Obj-c wrappers are present for almost everything).

Jack
Not everything has an Objective-C interface, particularly on the Mac. There are even lots of system APIs that only come in C. And many kinds of apps need C for speed (e.g. games very often use a lot of C, and there's no good Objective-C wrapper for OpenGL).
Chuck
OpenGL is not C, OpenGL is language agnostic.. and actually on ES2.0 is just made by shaders, with almost zero normal code.. then in any case if you don't know C neither Objective-C you are not going to write a game. And a game has an order of complexity that is not good to start from when learning a language..
Jack
+1  A: 

If you want to do Mac/iOS apps, just learn objective-C. I don't think you will "move up" from C to obj-c, rather you will just learn two different programming languages. Working in C is very different from working in C++ or obj-c. Mastering C will help you become... a master in C, not in obj-C.

I feel it's like saying that you should first learn how to ride a motorcycle in order to learn how to drive a car. Just because they both have wheels, doesn't mean it works like that.

On the other hand, if you feel C would be useful to you for some other reason (which it might very well be), there are many great books on C out there. I recommend the C Programming Language by Kernighan & Ritchie (often referenced just by K&R).

anothem
I don't really agree with this. People who only understand the object-oriented parts of Objective-C have a very shallow knowledge of the language and can't really do much beyond exactly what the frameworks provide. It's really not that different — it's just a set of object-oriented extensions on top of vanilla C, and for the most part could be (and originally was) implemented as a simple set of macros on top of C. The framework makes a much bigger difference than the language.
Chuck
That's true, but I would think that when learning objective-c one would not *only* learn the object-oriented parts of the language. What I'm trying to say is that if he is going to write code in objective-c, he should just start with that. I'm sure that in the process he would pickup a lot of knowledge about C itself, but that would be "secondary". I don't see the gain (strictly from the perspective of learning obj-c) in spending a period of time exclusively on learning C, before "moving on" to obj-c.
anothem
+2  A: 

It's not online, but to learn C, I recommend you read Kernighan and Ritchie's The C Programming Language, 2nd ed. (also known as "K&R"). It is a slim volume that communicates the fundamentals of C89. You can probably find it for free at your local library; that's what I did, anyway. C99 changed a few things, but the core of the language remained the same.

I don't recall whether it gets into the details of how an executable is loaded and linked and how the stack and heap are generally used. For that, check out the latest edition of Patterson and Hennessy's Computer Organization and Design: The Hardware/Software Interface.

If you already understand OOP, and you are conversant with C, then picking up Objective-C is as easy as reading through Apple's The Objective-C Programming Language and looking at a few examples.

Objective-C is simple, but the Mac/iOS frameworks are mammoth. Most of your time learning to program for Mac/iOS using Objective-C will be spent learning the frameworks and how to cooperate with the execution environment (NSApplication/UIApplication, NSRunLoop, the responder chain and event handling, etc.). You can get by with Apple's documentation, but Hillegass's Cocoa Programming for Mac OS X (currently in its third edition) is the standard non-Apple introduction to Mac OS X desktop programming. A clear standard introduction for iOS programming has yet to emerge, but I recommend Conway and Hillegass's iPhone Programming. After reading Hillegass's other book, you'll be comfortable and familiar with the didactic style employed in iPhone Programming.

Jeremy W. Sherman
Steve M
+1  A: 

Don't learn C to seed your learning for Objective-C, that step is unnecessary.

I come from a C# background, and when I first started learning Objective-C I had little C experience, which didn't inhibit me when working in Objective-C. The big thing you've got going for your is the OOP and software architecture. That will get you further than learning C.

I found that the best resources for learning Objective-C and specifically iOS programming can be found within Apple's documentation:

Another great resource is Cocoa with Love which is written really well and has some great content, specifically:

As well, I've found a lot of people like the AppsAmuck demos. Personally I found that they're coded quite poorly, but there are some good area specific examples for working with animations, urls, etc.

Gavin Miller
A: 

Scott Stevenson's Cocoa Dev Central hosts a lot of useful Cocoa tutorials, including a C tutorial for Cocoa programmers and links to several other useful resources on the topic.

Another good one is Masters of the Void by Uli Kusterer, a longtime Mac programmer.

Chuck
A: 

If you really want to learn C before Objective-C, go for it. For many people it's an unnecessary step, but you will use it eventually. If you decide that you want to skip learning C and dive into Objective-C, Kochan's book is a gentle "from the ground up" introduction.

For C, it's going to be better to get a book than try to find online tutorials. The classic text (like everyone here is saying) is the K&R C book. It's well known as the standard. The problem is that it's very dry and not that great for self-learning. It's more of a classroom book.

The best C book for self-learning is K.N. King's C Programming: A Modern Approach. It's pricey, but is very well paced, in-depth, has comprehension questions at the end of each chapter. I found out about this book from the guy who wrote the classic Objective-C book, Aaron Hillegass. He understands teaching and recommended it because it's a great book to learn from. It will help you to think about C and programming, where K&R will just inform you.

Personally, I gave up on my goal of learning C for iPhone programming and just learned Objective-C from Hillegass's book (and Jeff LaMarche's book). I get confused on the odd occasions that I have to write or understand C code, but it hasn't been a huge hurdle.

nevan