Learning C++ for the first time *gulp*

Discussion in 'Mac Programming' started by future macnerd, Feb 28, 2008.

  1. future macnerd macrumors member

    Aug 1, 2007
    Hello everyone, I was thinking of learning C++ for the first time, I have learned a few other more basic languages (html, other unheard of ones learned in school), and I was wondering
    A) what do I need to start learning C++? (application? i've used script editor for applescript, do I need a similar C++ application?)
    B) Where did you learn it? (books, sites, etc. probably more on the book side, I like keeping my monitor as "clutter-free" as possible.)
    C) any tips you could give me? (I've heard C++ is a very, very hard language to learn, especially for a beginner/intermediate programmer like me)
    Thanks for all of you who help :p
  2. Eraserhead macrumors G4


    Nov 3, 2005
    First I'd install the developer tools, i.e. Xcode. Its on the DVD that comes with your Mac, or you can sign up for a free ADC account to get it.
  3. tersono macrumors 68000


    Jan 18, 2005
    C++ is a Windows hodgepodge of a thing. Stick to Xcode and learn Objective C - a far more logical language, and one that's useful on a Mac.
  4. future macnerd thread starter macrumors member

    Aug 1, 2007
    thank you very much, but I have two questions,
    1. is ADC still 18+ only? because last time I checked (i think it was ADC) it was 18+ only and I'm a Freshman in HighSchool....
    2. what exactly is C-? is that a language too or just a "variation" of C++? and is it compatible with as many things? because I was learning C++ for the great base it would give me and also I was planning on working on a server for the game World of Warcraft with some people I know.... :p
  5. kainjow Moderator emeritus


    Jun 15, 2000
    I learned it in college a few years ago.

    I wouldn't say it's hard. It's like learning to drive when you don't even know what a car is. Baby steps ;)

    C++ is so much more useful for general development though. You can use it on all operating systems, where Objective-C is really only useful on the Mac.
  6. kuwisdelu macrumors 65816

    Jan 13, 2008
    1. Yes, ADC is still 18+, but you don't need that to get the XCode developer tools. It was just a suggestion. XCode can be found on your installation DVD. Just grab you OS X DVD and install the Developer Tools.

    2. Objective-C is a superset of C, and C++ is also a superset of C. Objective-C is an object-oriented language just like C++ is, and they both are the grandchildren of the C language. Objective-C is the language used to program most native Mac OS X applications using a framework called Cocoa. If you want to learn to program for a Mac, you'll want to learn Objective-C, but IMO C++ is a much more versatile language if you want to program in other areas. There are lots of programs in C++ from the data analyzers used in High Energy Particle physics at CERN to Adobe's Photoshop.

    C++ is NOT a "Windows hodgepodge of things." It has nothing to do with Windows at all. You're thinking of C# which is (again, IMO) an ugly Windows .NET-like corruption of C++ that shouldn't exist. But hey, we're all entitled to our own opinions.

    So, OP, I say to go right ahead and learn C++. I learned it from a book. Most will come with CD's that have tools to compile your code, but they usually don't have Mac versions, so you'll need XCode. XCode is kind of hard to learn, but it's pretty simply for console output in C++ if you just make sure to make your new projects "Standard C++ Tool" type (I think that's what it's called). It's really not too difficult, although it's very, very different from HTML if that's what you're used to. Make sure to understand what Object-Oriented programming is as you learn it (it's okay if you don't yet, any good book should tell you). C++ is a good compatible, widespread language.

    If you decide you'd like to program applications for the Mac, however, you really should learn Objective-C, too ;)
  7. lazydog macrumors 6502a

    Sep 3, 2005
    Cramlington, UK
    That's a bit of sweeping statement!

    Lots of reasons for learning C++, including more job prospects…

    Also, if you have C++ under your belt, you can use the Objective-C++ compiler and have the best of both worlds on the Mac. For example, you can use the STL. (future macnerd: If you're learning C++ you will soon run into the standard library (STL). It's an incredibly useful thing to learn but it can be daunting if you dig too deep into it… so don't be put off using it because things like vector and set are easy to use and very powerful).

    b e n
  8. future macnerd thread starter macrumors member

    Aug 1, 2007
    Thank you all very much, I'm a little bummed that I can't join the ADC... I've heard it has great benefits, I think I will go out and buy a book, (probably at borders unless there's a specific place to go, and probably something to the effect of C++ for dummies), I think I will learn C++ first and then probably project-C, and maybe C if it would still help, and I never got that "used" to html so I hope I'll be fine, just one last question though. Is this something I should wait until the summer to start? or can I learn it relatively casually depending on my HW/plans/sports/other things?
  9. Cromulent macrumors 603


    Oct 2, 2006
    The Land of Hope and Glory
    Just lie about your age when you register. Not that much of a problem.

    I think you mean Objective-C not Project-C :). As for learning, don't expect it to happen over night or in fact in a month. You can learn all the keywords in a language in a weekend. Learning how to actually write programs is a whole different issue though.
  10. kuwisdelu macrumors 65816

    Jan 13, 2008
    Depends how "into" it you want to get. I'm sure you'll be able to get somewhere just learning it casually, but if you take too long between reading chapters, or decide not to bother trying out some code, you may not learn it as fully as you want, or find yourself rereading old sections because you forgot what something does.

    How much time do you have right now? It's certainly something you could try to learn casually beside schoolwork, but you may not get the most out of it.

    I think it would probably be best to devote some time, say, an hour or two each day to reading a chapter and trying out some new code and personal projects and that kind of thing. There's no reason you can't start now and if it seems like you have to keep looking back over old chapters because nothing makes sense, then stop for a while and hold off until summer. That's probably what I'd do. See where you can get right now and if it gets too complicated, wait til summer.

    As for books, Borders or Barnes&Noble should have plenty. I suggest you find one with quizzes and exercises/homework projects at the end of each chapter so you can see how you're progressing. Remember, programming is such that you will always feel whatever you're working on right then is the hardest thing ever, but once you move on to the next thing you'll be thinking "what I just did was so easy compared to this!" and find that new thing the hardest thing ever, until you get to the next...and so on, so if you ever start feeling that, don't worry! It's completely normal ;)
  11. kuwisdelu macrumors 65816

    Jan 13, 2008
    Won't work. The age part, maybe, but the OP said he's still in high school. You have to prove you're a university student by sending Apple your course list or your university ID number.

    Don't worry, though! You'll be 18 soon enough, and there are plenty of resources out there, still. XCode is still free on any install DVD, after all.
  12. sord macrumors 6502

    Jun 16, 2004
    Be careful what book you buy -- I've seen a lot of books written by C programmers for C++ that don't teach you how to properly use C++.

    I suggest getting a copy of Jamsa's (or Jasma's, can't remember) C/C++ Programming Bible if its still available (amazon.com probably). It does a great job of explaining both C and C++, but separately and in a way that I certainly liked when I was using it as a reference.
  13. sord macrumors 6502

    Jun 16, 2004
    He can still sign up for the free ADC membership, which will get him XCode. Not sure about age but you certainly don't need to provide that information.

  14. kuwisdelu macrumors 65816

    Jan 13, 2008
    Good point!

    One way to check this (though definitely not foolproof)--look through the book and if you see lots of "printf"s instead of "cout <<"s then grab a different book.
  15. kuwisdelu macrumors 65816

    Jan 13, 2008
    Hmm, I guess I was thinking of the student ADC membership that comes with the one-per-lifetime massive hardware discount and other such things, which I know requires such information.

Share This Page