[OT] memory management -- was Re: itoa'd you so?

Dave Smith dave at thesmithfam.org
Wed Sep 19 22:26:27 MDT 2007

Levi Pearson wrote:
> C++ is hugely complex and has a myriad of ways to do things, so it's really a tool that requires deep knowledge of the language, available libraries, and best practices to use well.

I disagree with 2 of your 3 statements and only partially agree with the 
other. Let me respectfully address them below, in the interest of an 
edifying discussion. Please set me straight where I err.

First, you contend that you must have a deep knowledge of the C++ 
language to use it well. Let me address that point last, because I 
partially agree with you on that one.

Second, you contend that you need deep knowledge of available libraries 
to use C++ well. Is that not also true of all languages? Those who are 
ignorant of the useful libraries in their language of choice are doomed 
to reimplement them. This surely applies to all languages. Are you 
perhaps inferring that C++'s standard library is so lacking that you 
have to go to outside sources to make it usable? If so, I agree, but 
Google can help. However, I still contend that in order to make good use 
of any language, you have got to be familiar with the available 
libraries. This is especially true of Java, which alone isn't much of a 
tool, but when coupled with the myriad of outside libraries, it's pretty 

Third, you contend that you must know C++ best practices to use it well. 
Are you saying that there are languages that *don't* require developers 
to employ best practices to use the them well? I think this is common to 
all languages. Perhaps you are inferring that because there are so many 
ways to do an individual task that it is too hard to guess the best one 
without a deeper knowledge?

Now back to your first argument, that you must have a deep knowledge of 
the language to use it well. I don't think this is entirely true. You 
certainly have to know some things, on which topic I have two pieces of 

1. You should find some well-written C++ to pattern after (which might 
prove difficult because so few people seem to follow my next point).

2. You need to read a few entries in the C++ Super FAQ and a few pages 
from the beginning of Josuttis's book, The C++ Standard Library (which 
pages incidentally have nothing to do with the C++ Standard Library but 
cover basic C++ language features).

If you do those two things, you'll be in good shape to code lots of 
awesome C++.

You certainly don't have to understand some of the language's cobweb 
filled corners like virtual inheritance and the unfavorable diamond or 
recursive template meta-programming to be a good C++ developer.

Here are a couple other examples of why C++ is a great programming language.

1. Qt's foreach macro. The language designers did not write a sane 
foreach. In fact, the one that ships with the standard library is a 
steaming pile of unusable poo (unlike most poo which is not steaming and 
at least somewhat usable), but Qt managed to use cool language features 
to make a nifty, useful, and type-safe foreach macro that *feels* like 
part of the language despite being added many years after the most 
recent language revision.

2. Macro-based debugging. Using the macro system, you can remove and 
insert entire chunks of code just by flipping a flag in your makefile. 
In other languages (like Java and Python), you'd have to do some serious 
magic to actually *remove* debug code from your software at release 
time, rather than just wrap them in false conditionals, to get the same 
kind of performance as C++.

3. A linker! Why don't other languages have linkers these days? It's 
such a pain to kludge together jar files that you hope have all the 
classes you need to ship in one bundle. I know the Mono team is working 
feverishly to finally write a linker after how many years? Using a C++ 
linker, I can create a single binary that will run on just about every 
Linux distro (even spanning kernel versions).

4. Templates. Templates are cool when used properly, and type safe. Of 
course, templates can be abused, so use with caution. This is one of 
those areas that requires a little bit of "deep knowledge." :)

5. Speed. For most user-interactive desktop applications, you still 
can't JIT fast enough to match C++'s raw speed.

Anyway, I'll get off the C++ pedestal. Sometimes I feel like I'm still 
rooting for the losing team, but for certain applications C++ is just 
great, even if your last name isn't Stroustrup.


P.S. I had to add "poo" to Thunderbird's spell checker. How poopy is 
that? (I had to add poopy too)

More information about the PLUG mailing list