[prog] Another C++ problem

Robert J. Hansen rjh at sixdemonbag.org
Wed Apr 23 03:53:34 EST 2003


Warning: opinions herein!  While I like to think I have some good, solid
reasoning behind these opinions, please do not read them as
incontrovertible fact.

> Thank-you for all you comments, I will now go through these 2 programs again 
> and use the insights that you have given me.  (And I am going to relax and  
> not expect it to all make sence for about 2 months - a little at a time.  I 
> think that I had unrealistic expectations).  

A couple of remarks:

1.  There's a _lot_ of really lousy C++ code out there.  I've seen
several mass-market C++ books in which all their code examples have
"void main(void)" (which is definitively __not__ C++), and other books
which teach C-style syntax and language constructs before C++.

Avoid these books if at all possible.  The fewer bad habits you learn
now, the fewer you'll have to unlearn later.  C++ has several strong
advantages over C (strings, the STL, and streams, just to name three
clear winners); the sooner you start using C++ idioms, the sooner you'll
be a proficient C++ programmer.

If at all possible, find good C++ code.  Find code that makes good use
of C++ idioms and practices.  Don't look for code which uses every weird
C++ feature.  Evaluate C++ code much like you would a novel: look for
code which has a distinct "flavor", a distinct metier and crisp style. 
Learn why the style works (or why it doesn't work), and use what you
learn to develop your own style.

Web resource: Bjarne Stroustrup's "Learning C++ as a New Language". 
http://www.research.att.com/~bs/new_learning.pdf  -- read this paper,
read it a couple of times.  It will, hopefully, give you some insight
into learning C++.  

While you're there, check out his paper "Sixteen Ways to Stack a Cat". 
Funny, interesting and educational.  :)

Also: http://www.research.att.com/~bs/slashdot_interview.html




2.  Don't expect to understand C++ in a matter of months.  You probably
won't.  I've been using C++ since 1989, and after 14 years of using it I
still discover new and odd things I can do with it.  C++ is a
phenomenally rich language, probably as rich linguistically as Perl is. 
It's not a language you'll learn in a few months, or even a year.

In a year you can certainly learn enough of the language to use it
profitably to solve programming problems.  Just like after a year
overseas in a foreign country, you can certainly learn enough of the
language to get around, order meals, carry on conversations.  But
becoming fluent in it--learning how to create /art/ with it--that will
take years, years, years.

But the investment is well worth it.  :)

-- 
Robert J. Hansen <rjh at sixdemonbag.org>



More information about the Programming mailing list