Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ coming from Java and Objective-C

So, I know both Java and Objective-C quite well, but (perhaps strangely) never really learned C++. Obviously, the languages are all related, but there are syntactical differences that I don't fully understand. Is there a nice document that describes the basics of C++, but still assumes the learner knows a programming language? Perhaps even a tutorial that aims to describe the differences between the languages. This is what I'm looking for.

Also, is there a good tutorial on how to use C++ code inside a Mac or iOS app? The reason I feel the need to learn C++ is I'm trying to port a C++ program, and I heard you can use C++ code and just wrap it in an Obj-C GUI. Could someone point me to some documentation/tutorials on how to do this?

Thanks!

like image 577
Alexis King Avatar asked Jul 10 '11 20:07

Alexis King


2 Answers

Even though the languages of this family are all related, that does not mean that you can casually move from one to the other and expect to write beautiful code. You have to learn the language's idioms and idiosyncrasies, and experience its strengths and way of thinking.

I would recommend reading Stroustrup's original book (a modern edition, of course). It's the most definitive reference (short of the actual standard) and it is very clearly written. The benefit of this approach is that you will be taught to think "how would I do this in C++", rather than "how do I transliterate this piece of Java code to make it compile". (Also this approach does away with any risk you might have of thinking you should "learn C first". Don't.)

On MacOSX, either download and build the free GCC, or get XCode (which comes with GCC). For iOS I don't know, I have a suspicion that you cannot deploy native code on it.

like image 111
Kerrek SB Avatar answered Oct 02 '22 16:10

Kerrek SB


I would go for a pure C++ route, the quality of the material being the guide rather than finding ObjC+Java->C++ material.

At the university I am working for we have tried both ways for teaching C++ to students with a lot of programming experience, in particular Java experience, for obvious reasons.

The conclusion was that the specialized course did no better in teaching C++ than the generic one with some extra exercise materials. It's the quality of the teaching materials that matters.

Edit: You will probably receive a lot of good answers on the actual differences, also Voo's comment on your question is relevant.

like image 40
Captain Giraffe Avatar answered Oct 02 '22 15:10

Captain Giraffe