Expert C Programming

(Jeff_L) #1

  1. [2] would cause run-time or space overheads for a program that did not use
    it.

  2. [3] would increase run-time or space requirements for a C program.

  3. [4] would significantly increase the compile time compared with C.

  4. [5] could only be implemented by making requirements of the programming
    environment (linker, loader, etc.) that could not be simply and efficiently
    implemented in a traditional C programming environment.


Features that might have been provided but weren't because of these criteria include garbage
collection, parameterized classes, exceptions, multiple inheritance, support for concurrency,
and integration of the language with a programming environment. Not all of these possible
extensions would actually be appropriate for C++, and unless great constraint is exercised
when selecting and designing features for a language, a large, unwieldy, and inefficient
mess will result. The severe constraints on the design of C++ have probably been beneficial
and will continue to guide the evolution of C++.


Ah, What years those were! The Reagan years, when tomato ketchup was a vegetable, trees
were the major source of pollution, and C++ was assured of remaining unencumbered by
parameterized classes, exceptions, and multiple inheritance.


If I Was Going There, I Wouldn't Start from Here

There is a property of programming languages known as orthogonality. This refers to the degree to
which different features follow the same underlying principles. For example, in Ada, a programmer
who learns how packages work will be able to apply this knowledge to generic packages, too.
Unhappily, much of C++ is quite unorthogonal. Mastering one feature in C++ provides no clue or
mental model that can be applied to other features. Most programmers will take the approach of only
using a simpler subset of C++.


Software Dogma


A Simple Subset of C++


C++ features to use:



  • classes

  • constructors and destructors, but only with very simple bodies

  • overloading, including operator overloading and C++ I/O

  • single inheritance and polymorphic functions


C++ features to avoid using:



  • templates

Free download pdf