Re: [ANN] You Can Program in C++ (book)
darkknight <darkknight.21@gmail.com> wrote:
Can you give an example of a C++ book that you think is C with C++
added as an afterthought?
I tend to avoid such books and I try not to clutter my memory (nor
bookshelf) with them, but from time to time I do stumble upon some.
Actually, there *might* be one sitting in dark corner of my bookcase,
that's Shtern's "Core C++". Oh, and I "learned" C++ from such handbook
and then wasted 10 years of my professional life - but in 90's good
C++ handbooks were much harder to find than they are now. Thanks to Herb
Sutter and his "Exceptional C++" I started learning the language almost
from zero and I loved it.
Can you give an example of a C idiom that "does not really help
maintaining code dependencies"
off the top of my head:
- Hungarian notation
- use of multiple function names where overloading would make more sense
- writing large functions with single point of return
- exposing class implementation details which effectively makes them
structs
And the other side of the coin is:
- compensating for perceived "lack of C-plus-plus-ness" by overuse,
misuse and abuse of inheritance, overloaded operators, exceptions etc.
Even worse, this is what some poor "C++ handbooks" do - they introduce
C++ as mixture of these new cool features with no explanation how to
use them, at the point when reader is already full of C and the only use
he may put them to is in C programs that he just learned to write. And
that's exactly how C++ programs shouldn't be written - these concepts
have to applied in program from the start, not as an afterthought.
Both problems come from not understanding what really C++ is and poor
handbooks are mainly at fault. The problem is so wide that number of
good C programmers shudder when they have to deal with inheritance,
exceptions, templates or other things that differ C++ from C - as they
never learned C++ . Worst thing is that they think they know C++ -
because they actually made effort to learn it (and just happened to
choose wrong handbook).
and explain exactly why learning it
disadvantages a C++ programmer.
here is perfectly fine piece of C code:
char* pa = malloc(20);
if (pa)
{
/* do something with pa */
free(pa);
}
.... but when you learn that "in C++ we use new instead of malloc" and
try to aply this knowledge to above code, not understanding what
exceptions are, yet (they are introduced 3 chapters later, if reader
happens to reach them), that's recipe for distaster. And I see these
disasters happening all the time.
B.
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]