I wanted to post this yesterday, but the boards were inaccessible:
C++ is evil, especially as a learning language, for a number of reasons:
Good didactic languages (like Pascal, Modula, Java, Smalltalk, Python) are clean, straightforward and built to encourage one programming paradigm. You don't want to distract students with convoluted grammars riddled with inconsistencies and exceptions, lots of fiddly things to remember, and no gestalt
- no overarching, unifying paradigm. Unfortunately, C++ has a convoluted and inconsistent grammar, convoluted semantics, lots of fiddly things, and no gestalt. It's the most designed-by-committee language that I've ever seen, and I've seen a lot of them (including old warhorses like PL/I and COBOL).
C++ is built on C. Unfortunately, while C is elegant on its own terms, it's difficult to master, and its strengths have very, very little to do with OO programming - or for that matter, with contemporary coding standards. Furthermore, its terms aren't terribly relevant anymore - not many people choose languages that were designed to be easy to write compilers for. C++ is so vast and so complicated - in addition to inheriting C's complications - that there are large gaps in feature implementations between compilers, countless bugs, and a shortage of accurate and readable books.
I have two C++ books, one well-known and regarded, that totally flunk out when attempting to describe the behavior inherited from C. They're simply wrong. The OO coverage in both is good, fortunately, but this illustrates where C++'s attempt to please everyone starts backfiring: It brings to mind the old joke that every COBOL (or PL/I or Ada) programmer writes in a different language. And the world is littered with "C++ programmers" who know maybe
50% of the language. Maybe. This is the source of endless quantities of bugs, because one of the most difficult aspects of C (and therefore C++) to master is the way it handles expressions, and (obviously) that's also one of the most basic functions of the language. If you don't know how expressions work in the language you're using, all the OO methodology in the world isn't going to help you. And expressions are precisely where the book I referred to (Practical C++ Programming
- admittedly, an older edition) goes wrong!
OK. Now onto the other major disadvantage: C++ is not an object oriented language. It isn't. It has, as part of its endless list of bolted-on features, objects and classes and inheritance, but you have to have a very clear vision of how you want to organize your code, and what features you want to use how (and the caveats from the above paragraph applies: You have to know how they work, and you have to hope the compiler implements them) in order to use the language well. And, of course, if you're just learning to program, you don't have any of those abilities at your disposal.
The argument that students need to learn on C++ because the market uses C++ is absurd: Programmers need to learn how to program, and that is essentially applied mathematics. A good programmer can design software on the back of a napkin, and then implement his design in whatever language he chooses to. That is what students should learn to do, and the best languages for the job are the ones that get out of the way and let the concepts shine through clearly. Java is OK for this (it's a bit too C++-ish). So is Python. Purer, simpler languages like ML, Prolog, Scheme, and Smalltalk are best (remember, it doesn't matter if you never use them professionally) because they allow you to clearly and concisely explore the logical and organizational aspects of programming, which are by far the most crucial.
For actual development, you might want to learn C++ just because it will help put food on your table (for that matter, so will Visual Basic - and don't get me started on Visual Basic). The advantages of "slower" languages like Java, Objective-C, Python and Perl lie in the time it takes to develop programs with them, and the ease with which those programs can be augmented, debugged and supported. If you're planning on working by yourself or with a small team, they're by far the best choices.
The debate about the intrinsic speeds of languages is by and large moot. A talented programmer with an interpreted language can beat a mediocre programmer writing in C or FORTRAN every time, because appropriate choice of algorithms and program design are the most effective optimizations. If you want to pick nits, though, Objective-C has several advantages over C++: Its class hierarchies are much flatter (less searching the inheritance trees), and you can use it almost like a pure OO language to rapidly develop a fully functional - if slow - version of your program and then take advantage of optimization to make it fully functional and fast. At full speed, Objective-C is every bit as fast as plain C is.
If you do decide to learn C++, I'd recommend studying C alongside. Be patient: By my estimation, it takes at least a year to get really comfortable with C. The <a href="http://www.eskimo.com/~scs/C-faq/top.html
" target="_blank">FAQ for the comp.lang.c newsgroup</a> is a great help with some of C's more common gotchas. Kernighan and Ritchie's <a href="http://shop.barnesandnoble.com/textbooks/booksearch/isbninquiry.asp?userid=0IGMVG9LW0&mscssid=6XPCFX69
8QM19MN9LQ2XU3N2BM4N85W5&isbn=0131103628" target="_blank">The ANSI C Programming Language</a> is an invaluable reference, although it's a bit too dense to be a tutorial. Stanley Lippman's <a href="http://shop.barnesandnoble.com/textbooks/booksearch/isbnInquiry.asp?userid=0IGMVG9LW0&mscssid=6XPCFX69
8QM19MN9LQ2XU3N2BM4N85W5&isbn=0201485184" target="_blank">Essential C++</a> and <a href="http://shop.barnesandnoble.com/textbooks/booksearch/isbnInquiry.asp?userid=0IGMVG9LW0&mscssid=6XPCFX69
8QM19MN9LQ2XU3N2BM4N85W5&isbn=0201824701" target="_blank">A C++ Primer</a> are the best books I've seen on C++.
If you start with Objective-C you'll need to know less C, but the above recommendations still hold. Your best resources here, besides Apple's documentation, are the comp.lang.objective-c newsgroup, OmniGroup's mailing lists, <a href="http://www.stepwise.com/
" target="_blank">Stepwise</a>, and <a href="http://mac.oreilly.com/
" target="_blank">O'Reilly's OS X pages</a>. I've heard a lot of good things about Aaron Hillegass' <a href="http://shop.barnesandnoble.com/booksearch/isbnInquiry.asp?userid=0IGMVG9LW0&mscssid=6XPCFX69
8QM19MN9LQ2XU3N2BM4N85W5&isbn=0201726831" target="_blank">Cocoa Programming for Mac OS X</a>, so I'll pass that along. You'd think that Apple's own offering, Learning Cocoa
, published by O'Reilly, would be good, but it underwhelmed me.
Hope this ridiculously long-winded post was of some help.