Avizz
Avizz

Reputation:

Is C hard to learn if you know Objective-C

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

Upvotes: 4

Views: 1424

Answers (8)

Avizz
Avizz

Reputation:

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.

Upvotes: 0

Jonathan Sterling
Jonathan Sterling

Reputation: 18385

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.

Upvotes: 1

John
John

Reputation:

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

Upvotes: 0

Rob Napier
Rob Napier

Reputation: 299605

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.

Upvotes: 2

Louis Gerbarg
Louis Gerbarg

Reputation: 43462

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.

Upvotes: 1

micmoo
micmoo

Reputation: 6091

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.

Upvotes: 0

Kredns
Kredns

Reputation: 37231

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:

Upvotes: 4

Pavel Minaev
Pavel Minaev

Reputation: 101665

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

Upvotes: 5

Related Questions