tags:

views:

411

answers:

8

I'm in the process of teaching myself Objective-C via Stephen Kochan's "Programing In Objective-C 2.0" It's a great book and currently reading it for the second time, first time I got the gist of it and now it's really starting to sink in the second time.

If you have a moderate (about) knowledge of Objective-C, how difficult would it be to learn C? I realize there is seemingly endless debate on which language to learn first. I decided to go with Objective-C because I was interested in Cocoa Mac Apps/iPhone apps.

Side Note: For those familiar with the Chipmunk Physics engine... The reason I may start pursuing C eventually is that it uses C. How much C would I need to know to adequately use it. I was going to use it along with Cocos2d which uses Objective-C

+5  A: 

Given that C is a strict subset of Objective-C, if you truly fully know Objective-C already, you know C as well.

Pavel Minaev
The OP's question relates to a moderate understanding of ObjC, which represents a broad set of patterns that are very different from C patterns. You could develop Cocoa apps for years and never have to call memcpy(). Even a novice C programmer must understand memcpy().
Rob Napier
I don't fully know Obj-C, still sorta new to it, when I do start to pursue C I'll probably get a book. The same author of the book I'm reading has a book on C. I never liked online tutorials when it came to programing, just difficult managing to piece them all together to be beneficial.
@Rob Napier: I'm not sure that I'd pick on memcpy() as the archetypal must-be-known C function. I don't use it very often at all. It appears in 13 of 1070 C source files under my home directory, and at least 3 of the occurrences originate in code from other people. Now, had you picked on 'malloc()' or 'strcpy()', then I'd have been more in agreement.
Jonathan Leffler
+4  A: 

No. I learned C and I came from C#.

However it is really hard to find updated tutorials/blogs, here are a few that I used:

Blogs (only one I could find that's updated):

Tutorials:

Lucas McCoy
A: 

I learned C before I learned Objective-C, but the two have their similarities and differences. All the if statements, for & while loops are all the same in C, but how you GTD is different. Your not really exposed to the whole pointer thing in Objective-C, but that is super important in C, and the only way to get that down is reading and practice. It may seem daunting, but once you get the hang of it, its not that bad. Functions are a bit different then methods syntactically and how their called, so you will have to learn that also, but if you get a good book (http://www.amazon.com/Programming-Language-Prentice-Hall-Software/dp/0131103628) it shouldn't be that hard. Just read up and practice!

I also highly recommend the Stanford iTunes-U programming paradigms class, helps a lot learning about pointers, after you have a basic knowledge! Being a young programmer, it definitely helped me get a good grasp of it all.

micmoo
+1  A: 

Basically, C is Objective-C without:

  1. Anything involving message sending (all those [] brackets
  2. Anything that starts with an @ (the Objective C guys choose to use that in front of everything they added to make it clear what was an extension

Additionally there are a few things that are part of Objective-C but you might never actually use if you learned purely Objective-C. These are actually useful to understand since sometimes they are the best choice even in Objective-C code, and you might bump into them when you interface with other people's code. Things like:

  1. Function declaration syntax (no methods)
  2. Function pointers
  3. structs
  4. malloc()/free()

Over all I would think it is probably easier to move from Objective-C to C than it is to start learning C from scratch. That is just a guess though, I learned C first (around ~15 years ago) and have been writing Objective C code for close to a decade.

Louis Gerbarg
+2  A: 

C and ObjC have a lot of overlap, but their patterns are very different. Memory management in particular is radically different. Much of how you attack problems is very different. ObjC is all about relying on the framework and fitting into the framework and not getting in the way of the framework. In C, you're the bottom layer; libraries rely on you most of the time, not the other way around.

That said, if your goal is to write ObjC programs that incorporate C libraries, then learning ObjC first is definitely the right approach and Kochan's book is a great start (followed by Cocoa Programming for Mac OS X by Hillegass). Using an engine like Chipmunk or cocos2d is going to take care of some of harder details of C programming for you and definitely help ease you into learning your way around.

Rob Napier
You seem to be conflating Objective-C and Cocoa.
Chuck
Intentionally here. http://stackoverflow.com/questions/874690/is-objective-c-only-used-for-development-on-mac-os-iphone/874837#874837
Rob Napier
A: 

Pointers are what make C difficult, and it sounds as though they aren't a big part of programming Objective-C.

hrm, yes they are.
Luca Matteis
In my opinion, pointers are not too hard a concept to understand, it's more the ambiguous syntax chosen to represent pointers and dereferencing that make pointers difficult. `*((char**)aVoidPtr)[1] = "Confusing"`.
dreamlax
Pointer variables are widely used in Objective-C, but they aren't really used as pointers — they're just object references. You never dereference them and it's considered bad practice to do anything except assign them with the result of a method/function call.
Chuck
+1  A: 

Well, I would suggest getting some experience with C before delving into Objective-C. Why? Because Objective-C insulates you from a lot of the more complicated and interesting programming bits, like very manual memory management, crazy pointers, &c. Because Objective-C is a strict superset of C, there may come a time when you need to use these concepts, but without any C experience, it can be pretty confusing. I made the mistake of not spending enough time on C before jumping to Objective-C, so when I started working on more complex applications, I needed to do a lot of reading on C.

Jonathan Sterling
A: 

Chapter 13 "Underlying C Language Features" in Stephen Kochan's Obj-C book, appears to talk a lot about pointers, structures, functions, ect... with C. I never read it the first time around (it sorta suggested only read it if you need to) but after I read it the 2nd time I might go back and read Chapter 13, it should give me a good idea of C compared to Obj-C.