Pragmatic C++


A design goal of C++ is the expression of the solution in terms of the problem, not in the esoterica of the language.
 Myself on Hackaday

This is a different, even iconoclastic, introduction to programming the C++ language. I take this approach because of frustration with other presentations on the language. C++ is not, today in 2018, a modified version of the C language. It is a separate language deserving to be approached as such. It is equally valid to say Algol or Simula are forerunners of C++. Without those predecessors C++ might be a different language. Despite this ancestry it is its own, separate, modern language. 

Bjarne Stroustrup is the creator of C++. Here are his own words on the goals for C++ (Stroustrup 1995):

C++ was designed to support a range of styles that I considered fundamentally good and useful. Whether they were object-oriented, and in which  sense of the word, was either irrelevant or a minor concern:
[1] Abstraction – the ability to represent concepts directly in a program and hide incidental details behind well-defined interfaces – is the key to every flexible and comprehensible system of any significant size. 
[2] Encapsulation – the ability to provide guarantees that an abstraction is used only according to its specification – is crucial to defend abstractions against corruption.
[3] Polymorphism – the ability to provide the same interface to objects with differing implementations – is crucial to simplify code using abstractions.
[4] Inheritance – the ability to compose new abstractions from existing one – is one of the most powerful ways of constructing useful abstractions.
[5] Genericity – the ability to parameterize types and functions by types and values – is essential for expressing type-safe containers and a powerful tool for expressing general
algorithms.
[6] Coexistence with other languages and systems – essential for functioning in real-world execution environments.
[7] Run-time compactness and speed – essential for classical systems programming.
[8] Static type safety – an integral property of languages of the family to which C++ belongs and valuable both for guaranteeing properties of a design and for providing run-time and space efficiency. 

Since C++ started from C there is a great deal of commonality but sufficient differences to trap the unwary. The common approach to C++ is through C features with the addition of C++ features. My approach is to jump into C++ headfirst. The features obtained from C will be picked up along the way. You'll have to trust that eventually all will be explained. 

I'll mention that my quote above about the goal was commented on positively by Stroustrup in a short email exchange. 

Object Orientation or OO


We are surrounded by objects. Some are physical like the keyboard at your computer. It in turn is an aggregation of keys, springs, LEDs, and labels on the keys. Others are abstract such as a retiree, employee or manager. 

 
Comments