2
\$\begingroup\$

I'm a computer engineering student and taking my second programming class. I'm learning C++ using "C++ Primer Plus" 5th edition by Prata. I want to develop for iOS. I understand the main language for Xcode is Objective-C. Am I hurting myself by learning C++ before any other language (notably before my desired lang Objective-C)? There's got to be a reason the university requires C++ to learn as a basis language.

Please offer any helpful guidance or how I should go about this. Thanks//

\$\endgroup\$
4
  • 3
    \$\begingroup\$ No you're not hurting yourself at all. C++ is just a very widely used language, and that would be one reason why your university uses it. All languages are actually very similar, and when you understand how to produce efficient algorithms to solve specific problems, as well as how different data structures work, you can easily pick up any other language. \$\endgroup\$
    – Mick
    Commented Apr 11, 2012 at 3:46
  • \$\begingroup\$ Maybe I shouldn't do that, but I updated my answer multiple times. I will leave it at that from now on. \$\endgroup\$
    – Coyote
    Commented Apr 11, 2012 at 23:43
  • \$\begingroup\$ "There's got to be a reason the university requires C++ to learn as a basis language." Yes, but the reason for that is only answerable by the university department heads (or whoever makes the decisions). As far as I know, most universities are shying away form C++ as it's a very large language and complicated language and preferring to use things like python and java. \$\endgroup\$
    – Tetrad
    Commented Apr 12, 2012 at 15:41
  • \$\begingroup\$ Also this question is pretty subjective and probably a bit misguided. I don't know how "is learning <x> bad" could ever be "yes" other than the time/reward ratio you personally get out of it. \$\endgroup\$
    – Tetrad
    Commented Apr 12, 2012 at 15:43

5 Answers 5

8
\$\begingroup\$

Am I hurting myself by learning C++ before...

No, C++ is a good way to learn about all the basics of programming, including Object Oriented programming, and memory management which might be handled for you in other languages.

There's got to be a reason the university requires C++

It is an industry standard across the world. It is quite portable as there are compilers and implementations for most platforms.

notably before my desired lang Objective-C ?

Objective-C is contemporary of C++, they appeared around the same time and take different approaches when it comes to their Object Oriented paradigms. But they are both supersets of C and as such you can mix both.

My experience

The fact is most games I worked on for mobile are C++ games with some C, Objective-C or Java providing native functions to C++ in the game code.

I actually worked on only one Objective-C game. The dev time was shorter, but the game is now stuck as an iPhone only product.

Word: Rest assured that C++ is definitely the best choice of language you could currently start with. It's not the simplest, there are fewer standard libraries, memory management without smart pointers seems harder... But in the end, once you understand C++, you can approach other languages with a better understanding of what they provide, do and what they hide from you.


Another word: As a programmer you should not stop at one language. You will have multiple opportunities to learn other languages and different approaches... Don't shy away from acquiring these little skills and seemingly uninteresting languages. They make all the difference when you are faced with new (and increasingly challenging) problems, like building leader board servers, web games, massively distributed databases and games...


Note: If you learn both C++ and Objective-C at the same time, the experience shouldn't be too confusing as they are not so similar and the first approach of iOS dev quickly goes into the high level UI APIs while C++ digs into more low level things.

You might end-up favoring Objective-C as it comes with great APIs on Mac/iOS, it has a solid (for lack of a better word) memory management system, garbage collection, etc. But remember that in games development C++ remains the most used language

C++ deserves a place in every programmer's heart, mainly now there is much more to modern C++ than C with classes.

\$\endgroup\$
3
  • \$\begingroup\$ Nice stuff about C++ :) \$\endgroup\$
    – noob
    Commented Apr 11, 2012 at 12:09
  • \$\begingroup\$ Actually, C++ and Objective-C are both (loosely speaking) supersets of C. This is why Objective-C++ works - both languages have the C-like subset of functionality in common and (fortunately) have their additional parts largely orthogonal to one another. \$\endgroup\$
    – Mac
    Commented Apr 11, 2012 at 22:55
  • \$\begingroup\$ @Mac Indeed... Fixed. \$\endgroup\$
    – Coyote
    Commented Apr 11, 2012 at 23:05
7
\$\begingroup\$

You're not hurting yourself because you're doing what is required by your school. Learning to program is only partially about learning the syntax of a specific language (and it's a small part!). Right now you're learning to think logically and like a programmer. Don't worry about learning things you don't need, because it's all useful in some way.

\$\endgroup\$
2
\$\begingroup\$

C++ is where almost every new programmer learn about object-oriented designs first (at least in my area, it's true). So you are not hurting yourself. Also you can develop iOS (even Android )apps in C++.
If you are thinking to go into game-development, C++ is the de-facto language here, supported by most of the game-engines. So learning C++ is always a win-win situation whichever path you choose.

\$\endgroup\$
2
\$\begingroup\$

Objective-C is but one of many languages you can learn to use for iOS programming. Not only are you completely free to write C and C++ code on iOS (with some caveats), Apple also supports a language called Objective-C++, which is exactly what it sounds like.

While you do not need to use Objective-C to program your core application, the Apple APIs are all exposed in Objective-C. However, this matters a lot less than you might think. Well designed, well architected programs do not generally rely a lot on platform APIs (some exceptions apply). If you do your job right as a programmer then porting your application to other platforms should require relatively little of your application's code to be rewritten. This is done with the arts of abstraction and encapsulation. As an example, one engine I have now has less than a dozen Objective-C files but close to a thousand C++ files.

Regarding the choice of C++ as a first language, you should consider yourself very lucky. Most schools start with much worse first languages. You are unlikely to find any school that teaches Objective-C outside of a course or two on iOS development, and there's a reason for that. Especially when it comes to developing large, complex applications like games, Objective-C has a lot of weaknesses (all the weaknesses of C combined with all the weakness of a dynamic language, in fact) compared to C++, and you're going to be far better off having a solid grasp of all the tools that C++ offers. Learning Objective-C on your own will be very easy after you get a decent grip on C++.

\$\endgroup\$
1
\$\begingroup\$

Also (in addition to the other answers posted), objective C is a layer on top of C and most of the code you will be writing is c and c++.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .