Search This Blog

Sunday, April 26, 2020

Throwback - Introduction to C++

Migrating content from an even older blog.
The following content is from my very old blog which had to be removed due to discontinuation of the platform. I am positing it here as a new content.

THE ORIGIN OF C++

The C programming language was developed at AT&T for the purpose of writing the operating system for the PDP-11 series of computers which ultimately became the unix operating system. C was developed with the primary goal of operating efficiency.  Bjarne Stroustrup, also of AT&T, developed C++ in order to add object oriented constructs to the C language.  Because object oriented technology was new at the time and all existing implementations of object oriented languages were very slow and inefficient, the primary goal of C++ was to maintain the efficiency of C.
C++ can be viewed as a traditional procedural language with some additional constructs.  Beginning with C, some constructs are added for object oriented programming and some for improved procedural syntax.  A well written C++ program will reflect elements of both object oriented programming style and classic procedural programming.  C++ is actually an extendible language since we can define new types in such a way that they act just like the predefined types which are part of the standard language.  C++ is designed for large scale software development.

HOW TO GET STARTED IN C++

The C programming language was originally defined by the classic text authored by Kernigan and Ritchie, "The C Programming language", and was the standard used by all C programmers until a few years ago.  The ANSI standard for C was finally approved in
December of 1989 and has become the official standard for programming in C.  The ANSI standard adds many things to the language which were not a part of the Kernigan and Ritchie definition, and changes a few.  The two definitions are not absolutely compatible and some experienced C programmers may not have studied the newer constructs added to the language by the ANSI-C standard.

The best way to learn C++ is by using it.  Almost any valid C program is also a valid C++ program and, in fact, the addition of about 12 keywords is the only reason that some C programs will not compile and execute as a C++ program.  There are a few other subtle differences, but we will save the discussion of them until later.  Since this is true, the best way to learn C++ is to simply add to your present knowledge and use a few new constructs as you need them for each new project.  It would be a tremendous mistake to try to use all of the new constructs in your first C++ program.  You would probably end up with an in comprehensive mixture of code that would be more inefficient than the same program written purely in C.  It would be far better to add a few new constructs to your toolkit occasionally, and use them as needed while you gain experience with their use.

RECOMMENDED READING


  1. Brad Cox.  "Object Oriented Programming, An Evolutionary Approach".  Addison-Wesley, 1986.  - This book is excellent for a study of object oriented programming and what it is, but since it is based on Objective-C, it covers nothing of the C++ language or how to use it.
  2. Margaret Ellis & Bjarne Stroustrup. "The Annotated C++ Reference Manual".  Addison-Wesley, 1990. - This is the base document for the ANSI-C++ standard.  Even though it is the definitive book on C++, it would be difficult for a beginner to learn the language from this book alone.
  3. Scott Meyers.  "Effective C++, 50 Specific Ways to Improve Your Programs and Designs".  Addison-Wesley, 1992. - This book is excellent for the advanced C++ programmer, but it is definitely not for the beginner.

No comments:

Post a Comment