Using Xcode to learn C++
I'm interested in learning C++ for use in game development, and I know I need a compiler. I found out that Mac OS X users have easy access to either a built-in compiler or one from Xcode. My question is how do you use Xcode to create and test C++ programs? I haven't got an ounce of programming knowledge and the tutorials I've been looking at (this among others) say I don't need any experience, but I still don't understand how to write code and experience the results. Help?
Comments
If you already know C, then learn Objective-C, cleaner and simpler than C++, in addition it is the language for development on Mac OS X.
Unless your work requires C++, you have no reason to learn such a horrible language.
http://en.wikipedia.org/wiki/Objective-C
http://developer.apple.com/documenta...al/ObjectiveC/
http://www.gnustep.org/resources/ObjCFun.html
Avoid C++!
If you already know C, then learn Objective-C, cleaner and simpler than C++, in addition it is the language for development on Mac OS X.
Unless your work requires C++, you have no reason to learn such a horrible language.
http://en.wikipedia.org/wiki/Objective-C
http://developer.apple.com/documenta...al/ObjectiveC/
http://www.gnustep.org/resources/ObjCFun.html
But all of the sponsored Mac game engines are written in C++. And is C easier to learn than C++?
Also, does Objective-C even work on other platforms?
"Noooo! Swimming is bad! Here's a site on jogging..."
Capt. Falcon, if you want to learn C++, then learn C++. And you are absolutely correct, that most gaming engines require C and C++, so for *your* needs, C++ is almost certainly the way to go. The reason you're getting push back is because programming languages are a lot like religion - everyone picks one, and then insists it is the One True Way. Better to know a number of languages, and pull out the right tool for the job, IMO.
Objective-C is a *wonderful* language, and in my mind, a much better language than C++. C++ is sort of the kitchen sink approach to language design - it has every possible feature you could think of, but tacked on as an after-thought, and the end result is a convoluted mess. Obj-C is a beautifully elegant language, extremely well designed from the beginning, and offers features you *still* can't get in C++ without extreme contortions.
That being said, I do 95% of my current work in C++, because that's what the task called for this time around, but I vastly prefer Obj-C.
Obj-C has the strongest support on the Mac, but it's not Mac-exclusive. It's a supported language in gcc (the Gnu Compiler Collection), which is available for most every platform under the sun.
What *isn't* available on other platforms, however, are the Cocoa libraries, which are the magic secret sauce that make programming for the Mac so damned nice. Those are Apple's, and Apple's alone. (There is an open source effort to replicate them, called GNUstep, but it's probably three years behind at this point.)
Now, you may be thinking 'which one?', but Apple anticipated this, and came up with Obj-C++. The compilers Apple ships have been modified slightly (and the changes have, AFIAK, been handed off to the FSF for incorporation into the gcc mainline) so that you can have Obj-C code call C++ code, and vice versa. Which means you can use a C++ library from elsewhere, and hook into it from an Obj-C application you wrote specifically for the Mac. A lot (most?) of applications written for the Mac do this, since there's a wealth of C++ code out there to use. Ultimately, the question "Obj-C or C++?" has only one answer: "Both!"
So if you're looking at using gaming libraries that are already out there, you're almost certainly going to need to know C++. If you're interested in programming on the Mac, you're going to need to know Objective-C. Notice that both languages are based on C, so... start there.
C is a very low level language, and a pain in the ass in many ways, but it does form the core of both C++ and Obj-C, and will serve you well in those capacities. Once you have the basics of simple procedural programming down, you can start to investigate the differences between the dynamic and statically typed object models in Obj-C and C++, respectively. The two languages have differing philosophies on how to handle objects, but that's for another day, I think.
Avoid C++!
If you already know C, then learn Objective-C, cleaner and simpler than C++, in addition it is the language for development on Mac OS X.
Unless your work requires C++, you have no reason to learn such a horrible language.
http://en.wikipedia.org/wiki/Objective-C
http://developer.apple.com/documenta...al/ObjectiveC/
http://www.gnustep.org/resources/ObjCFun.html
So you are steering him away from the language that is used for about 75% of the programming in the gaming industry? That's intelligent. He specifically said he wanted to learn this for game development.
Obj-C theoretically works on all platforms, but practically it is a waste of time as a cross platform language. It is great for OS X development.
I would actually recommend learning Python first, as a scaffold to make basic programming concepts far easier. Don't look a it as a distraction. I find my students have learned programming far better starting with Python than when we had to start them with C, C++ or Java. Think of learning Python then C++ like learning to speak first, then learning to write. Both use the same rules, but speaking has less "overhead" or "decoration" to deal with. Imagine if we had to learn written language first, then were allowed to speak. That's like learning C++ first.
So my recipe is:
1) Install Python 2.6.x found here.
2) Use this online text: Think Python. Type every example into the Idle Shell [Applications/Python 2.6/Idle] which is installed with the downloaded Python packages. Do every problem.
3) Do some of the problems at Project Euler in Python for more practice. Yes Project Euler is all math, but game programming is almost all math so you cannot go wrong getting better at that frame of mind.
4) Come back and ask for a good C or C++ book to transition to that language. You will be able to pick up basic functional C orC++ in a mater of hours if you already have the Python clue grasped over a few weeks. The confidence and skills in logic you will already have will alow you to concentrate on C++ formatting rather than EVERYTHING ALL AT ONCE. Delving straight into C++ can take a couple months and require far more stick-to-it-iveness as there are lots of formatting gotchas which distract from learning the logic of programming. From there you can spend time learning the ins and outs of all of C++ as a game development language rather than spending days trying to figure out why some ridiculously simple program logic doesn't work, only to find that is was a misplaced formating widget, not a logic error.
And all I really wanted to know is how do you enter text into Xcode and see the results?