The Woods of Complexity
Well, I finally won at Stump the Compiler. That is, I asked it to compile a certain piece of template code and it replied with "Internal Compiler Error." I dont know whether to be proud of myself or embarrassed. Did I write something clever, or just subtly wrong? Perhaps both.
After much tinkering and experimenting, I finally got the code to compile, and that got me thinking. There is a new school of thought concerning how C++ ought to be taught to new programmers. It says they ought to be introduced to certain parts of the Standard C++ library, such as iostreams, std::vector, and std::string, very early in their curriculum. This enables new programmers to start writing interesting programs quickly, not just toy programs to add a couple of numbers, spit out a line of text, etc. For a good introduction to this approach, see Bjarne Stroustrups article, "Learning Standard C++ as a New Language," in the May 1999 issue of CUJ (also on his website at http://www.research.att.com/~bs/new_learning.pdf).
I think there is much to be said for making things as simple as possible for new programmers. The C++ Standard library does that, in a sense; it replaces (or hides) pointers and arrays, and the particularly unfriendly scanf and printf families of functions. Yet I have reservations about this new approach to teaching C++. It relies upon templatized constructs, such as vector and string, behaving like good abstractions which they do, if youre careful to make the right mistakes. I find these abstractions perilously thin veneers over a mass of complexity. In my experience with templates, it is all too easy to punch through the veneer; and when you do, God help you if you dont have good troubleshooting skills or someone to help you out.
Okay, so I am not a total believer in the new school, but I am not a total antagonist either. To prove it, I want to introduce CUJs newest columnist, Andrew Koenig. Andy probably needs no introduction to C++ programmers, but I will list a few of his impressive credentials: project editor of the C++ standards committee, former columnist for C++ Report, author/coauthor of three programming books. This first installment of his bimonthly column, C++ Made Easier (p. 42), is an excerpt of his latest book Accelerated C++, which he co-wrote with Barbara Moo. Accelerated C++ strongly promotes the new approach to teaching C++. Although I dont know how effective this approach is for newbies, I know that the code in Andys column has had a big effect on me. It makes me want to trash everything I have done to date and rewrite it. Andys code is that beautiful. I believe even experienced programmers could learn much about algorithm design and programming style, for example by studying Andys code. So I am very happy to welcome Andy to the pages of CUJ.
I remain an agnostic on the new approach to teaching C++; I prefer to let readers judge for themselves. For my part, if I were to stress anything that new programmers should learn, it would not be this language feature or that; it would be basic troubleshooting, which is both an art and a science, indispensable in all fields of engineering. Happy the student with faithful guides, who never steer her into the woods of complexity. Happier still the one who goes there anyway, and knows how to find her way out.
Marc Briand
Editor-in-Chief