C++ Programming Styles and Libraries
One of the main aims of C++ has been to make it an excellent tool for writing libraries. Here, I present some points about the role of libraries and of the programming styles that they support and rely on. For lack of space for a thorough treatment of these themes, I refer to books.
Introduction
C++ is a multiparadigm programming language. That is, C++ supports several styles of programming:
C-style programming. C++ is a better C, maintaining C's flexibility and runtime efficiency while improving type checking.
Data abstraction. The ability to create types that suit our needs.
Object-oriented programming. The idea of programming with class hierarchies and runtime polymorphism.
Generic programming. Programming using type parameterization of both datatypes and algorithms.
Importantly, C++ supports the use of combinations of those styles. This is crucial because the most effective programming techniques involve a variety of styles that people often classify as different. Radically different programming styles are often referred to as different paradigms; hence the word multiparadigm [Stroustrup,2001].
Naturally, this flexibility is viewed as mere complexity by people who think that there is one style of programming that is right for everyone. However, C++ is a general-purpose programming language with a bias toward systems programming, and none of the candidates for "the one right way" of writing programs adequately supports the range of needs faced by C++ programmers.
One group of programmers in particular needs generality, flexibility, and efficiency beyond what most programmers consider normal and reasonable: library writers. Many parts of C++ are best understood as facilities supporting library writers and library users. Think of it this way: Without a good library, most interesting tasks are hard to do in C++; but given a good library, almost any task can be made easy. Here "easy" means that the programming language isn't a source of significant complexity, so that a programmer can concentrate on the fundamental problems of the task in hand.