Take the 2-minute tour ×

I'm just beginning to learn Objective-C, and am finding that a background in C (which I don't have) is a useful starting point. I've dabbled in C++ so have some understanding of basic C++ paradigms and syntax. (FWIW, I have extensive experience in Java and higher-level languages like JavaScript and ActionScript.)

I'm interested in exploring iOS development, but a bit wary of focusing in on a language useful only on a single vendor's platform. I'd like to know more about how concepts I will learn as I proceed with Objective-C will transfer (or not) to knowledge of C and C++.

I'm interested mainly in core language concepts, but information on portability, frameworks, targetable platforms, etc. is welcome as well.

share|improve this question

closed as not a real question by BЈовић, Filburt, Bart, Pascal Cuoq, H2CO3 Oct 31 '12 at 7:39


Personally I don't think much will transfer at all. C was such a successful language (in it's day) that language inventors ever since have felt the need to name their languages after it, whether similar or not. –  john Oct 31 '12 at 7:29
This SO Question sums things up very nicely as far as the difference between C++ and Objective-C. A fundamental understanding of C will definitely be required, although the basic syntax (flow control etc) is roughly the same as C++. –  ephemera Oct 31 '12 at 7:40
@john “have felt the need to name their languages after it” and borrow the syntax of ({ }), and borrow the ugliest, most obsolete features of (*++p = *q++;), and borrow the weird type system of. –  Pascal Cuoq Oct 31 '12 at 7:40
@john - Both Objective-C and C++ include C as a subset, so basically the whole of C transfers. In the C++ case that's ignoring some issues with legal C identifiers clashing with new C++ keywords, if you're unfortunate enough to have identifiers like class or new. I've not used Objective-C, but I read somewhere that's supposed to be a strict superset of C - every legal C program is a legal Objective C program, there are no new keywords, only some new operator/punctuation tokens using characters that C only allows in string/character literals and comments. –  Steve314 Oct 31 '12 at 7:41
@Steve314 But there's so much more to a language than it's syntax. C, C++ and objective C encourage different programming styles. So techniques learned in one are not good programming in the other. –  john Oct 31 '12 at 7:43

2 Answers 2

up vote 21 down vote accepted

What you need to know: Objective-C is a strict superset of C, so everything that is valid C is also valid Objective-C. Objective-C just adds a thin object-oriented layer on top of C (in fact, the Objective-C runtime itself is implemented in pure C).

What I generally suggest to beginners is to master C first, because if they don't understand pointers, type conversions, variadic arguments, etc. they'll have serious headache during the development of The Worlds Best iPhone App Ever (TM). Until you don't master C, don't try to get into Objective-C and especially into the Cocoa Touch API, since it can be very confusing for a beginner in C.

Also, C is cross-platform, and is the language for native development, hands in hands with C++, from desktop computers through mobile devices to microcontrollers. It's a common conception that "if a system has a C compiler, that's enough to do anything that is available on the platform". Some people think that C is dead, but that's definitely not true. (According to statistics, at least - this chart suggests it was the most popular language in October 2012.)

C++: it is based on C, and also adds some object-oriented extensions to C, although it's not a strict superset of C. This means that you can write C code that is invalid in C++ or that does something different in C++ than that in C.

C++ is also a good language of choice for practically any kind of native development (and it's popular also), but again, it's a large language with a bloated grammar, and you also have to learn the concepts behind C before diving deep into C++, or you'll also have problems with the differences between pointers and references, operator overloading, name mangling, etc.

Well, that's it, pretty much. Conclusion: learn C very well first and you'll be in the possession of a powerful, cross-platform and widely used language; then learn Objective-C for iOS and Mac OS X development and C++ "just for fun" and for a handy and also powerful OO language.

share|improve this answer
Thanks, this is very helpful. I had a feeling this question might get shut down as too vague, but this is exactly the kind of context I was looking for. –  ericsoco Oct 31 '12 at 17:01
@ericsoco you're welcome. –  user529758 Oct 31 '12 at 17:56
@H2CO3 very nice example ..really it helped to learn some more –  SameSung Vs Iphone Nov 1 '12 at 20:44

C++ is Bjarne Stroustroup's language based on adding classes and metaprogramming to C in such a way that puts most additional work into the compiler, and relies on least possible effort at runtime.

Objective-C is Brad Cox's language based on adding a SmallTalk-style dynamic message-passing runtime library to C, with a small amount of syntax addition to make it easier to use.

Objective-C++ is, to put it bluntly, what you get when you add the Objective-C runtime and syntax to C++. It has its limitations (e.g. you can't create an Objective-C subclass of a C++ class or vice versa, and Objective-C doesn't like C++ namespaces) but allows you to use C++ classes from Objective-C objects and vice versa.

You can use Objective-C++ in iPhone development. What this means practically is that you could write an application whose object model was entirely C++, where the controller layer would need to interface to Objective-C in order to use the Cocoa Touch APIs.

C is an "old" programming language. It is quite low-level, that means it is quite close to assembly and the machine code that actually runs on the processor. It is a procedural language. In a procedural language you focus on solving problems with step by step recipes. Recipes can be reused, this is called a function. As programs grow larger functions will typically be grouped out in separate files based on functionality.

Objective C keeps all aspects of C and allows you to build programs exactly the way you would do a C program if you want.

In addition Objective C adds syntax and semantics that allows for object oriented programming. Object oriented programming differs from procedural programming by focusing on grouping data and methods of manipulating this data in classes.

Usually you will be able to write any program using either C or Objective C, the difference is the approach you take to solve the problem. Some find it easier to think procedural for small problems, but objective oriented design has advantages when it comes to tackling large problems. First of all because it becomes easier to divide the problem into subproblems and submodules that can be developed and tested individually. Secondly because it is easier to reuse your own or other's modules.

share|improve this answer
C++ wasn't designed with metaprogramming in mind, it was accidental. –  Pubby Oct 31 '12 at 7:38
@Pubby if I can be sarcastic, I'd say "C++ wasn't designed with programming in mind, it was accidental"... I'm often criticized for agreeing with Mr Torvalds on his "C is better than C++" argument. –  user529758 Oct 31 '12 at 7:40
