[linux-elitists] Nobody's favorite language? C++ and free software

Ben Woodard woodard@redhat.com
Tue Mar 25 14:11:15 PST 2003

Disclaimer, I've been a nominal C++ advocate since 1989 when I first
used Cfront 1.1. Just after it changed its name from C with classes to

On Tue, 2003-03-25 at 11:25, Don Marti wrote:
> Is it my imagination, or is the number of useful free software
> projects in C++ on the rise?  (I'm partly going by my Linux Journal
> inbox here.)
> For example, Xerces and Xalan at apache.org are in C++.
> (Do the people at apche.org REALLY think that if you're trying to
> look up the web server docs and your fingers slip and you type their
> site instead, that you'll leave your server spewing 500s while you
> look at porn?  Never mind.  Dumb question.)
> As I was saying, C++.  It seems like this language is hard to
> mention without someone coming up with one of many common criticisms.
> A good example is this late 2000 Advogato thread, which covered
> some key objections to C++ among free software developers:
> http://www.advogato.org/article/207.html
> I've tried to list a few from that thread, this list, and other
> sources.
> 1. Everybody knows C, few people know all of C++.

My opinion is that C++ is a nice heavy lifting language. There is enough
in there that whatever programming paradigm happens to be applicable to
your task you have language support for it.

> 2. C++ is a Very Large Language
>   K&R, The C Programming Language, 2nd ed. -- 274pp.
>   Stroustrup, The C++ Programming Language, 3rd Special Ed. -- 1040pp.
> "It seems to me quite plausible that the complexity of the language adds
> to the time and cost of a full education in C++." -- Raph Levien

You don't have to use every feature. The worst C++ programs that I've
ever seen were those where you could tell that the author had just read
a book on C++ and had all the features fresh in their mind and tried to
use them all in their program.

In my opinion a good C++ programmer exercises restraint. There are coils
and coils of rope for you to hang yourself with. With C++ you use the
features which make your programming job easier not more cumbersome.

Like another responder to your query, I have a particular subset of
features that I use. The rest don't apply to the kind of programming
that I do.

> 3. Unstable C++ ABI in late g++ 2.9.x, early 3.x
> 4. Some compilers still don't support ISO standard C++, so
> real-world projects end up falling back to a conservative but
> ugly subset that doesn't offer compelling advantages over C.
> (see, for example http://www.mozilla.org/hacking/portable-cpp.html)
> 5. GNU tools are slower at building C++ projects than those in C.
> 6. Binaries are "huge."

There are three things that need to be pointed out here:

1) For a long time the linkers and the way that the libraries were
written were really bad and any time you used the std lib (and its many
templates) you would get lots of copies of almost identical code. Things
are much better now.

2) The debugging symbols are much more comprehensive. If you strip your
binary it usually shrinks immensly.

3) The libraries are much more full featured. So you will have bigger

> 7. C++, because of its corporate success, is associated with non-fun
> projects.
> 8. Not enough beautiful free C++ code to set a good example, while
> there's lots of beautiful C.

In a lot of ways, I think that the free software world would be a better
place if everyone switched to C++ or at least glib. There are so many
hand written implementations of linked lists, hashes, sets etc... and
many of them are subtly broken or poorly optimized. If people would use
good well written libraries rather than rolling their own fundemamental
data structures I think free software would improve considerably. 

It is almost true that anything that you can do in C++ you can also do
in C (exception handling may be the exception) and that C++ just puts
semantic sugar on it. However, in many cases doing the same thing in C
is extremely ugly. If you compare the readability of OOP code done in C
vs. OOP code done in C++ the difference substantial. One may argue "then
don't do OOP in C". The problem is people do do OOP in C. At least C++
makes it clean, tidy, and readable. 

> My question is -- now that we have GCC 3.2.x
> (http://gcc.gnu.org/gcc-3.2/ -- "A primary objective was to stabilize
> the C++ ABI; we believe that the interface to the compiler and the
> C++ standard library are now relatively stable.") and an increasing
> collection of interesting free software using C++, is it time to
> take a second look at this perhaps unfairly maligned language?

I'd say "yes". I think C++ is a more expressive language and can provide
programmers more leverage in working on big problems than C does.

More information about the linux-elitists mailing list