Guides to Programming Languages & Related Topics

Index

C++

Bell Labs again

The research and development office at Bell Labs (part of AT&T) NY was where Bjarne Stroustrup wrote C++ in 1983. Bjarne's colleague Dennis Ritchie designed C in the same offices years earlier.

A more expressive C

C++ was originally called "C with classes". C++ was designed to improve the C language by using additional programming features. Any C code will work when built as a C++ program. But C++ programming, using the new features, requires a different way of thinking about writing software than with C programming.

C++ has objects but is not a pure OO language

Underpinning this new C-type language was the addition of object oriented (OO) features, in the original name "C with classes" a class is an OO term. Object oriented languages can help reduce the complexity of software and make it easier to think about writing coherent software.

C++ is not a "pure" OO language. Use of the OO features is not mandatory. It's design is a comprimise: the aim was to produce a language capable of similar performance to C programs, but with more features to make programming of complex software easier.

C++ Templates and the STL

C++ templates were added to C++ later. What are templates? Let's consider an example.

We want to be able to count any list. Count the number of names, or the number of dates. In these simple cases, a parrot would be able to count that there five names, four dates and six numbers. But of course we may wish to count far larger amounts as well (thousands or millions of names for example). There at least three different types of list to count (names, dates, numbers)- there could be others. In C++, before templates, we would need at least three count functions, one for names, one for dates, and one for numbers. With C++ templates, only one count function is needed. With templates, only one count function will be needed to count all these different types of list. This ability to simplify code for many types of data is known as type paramerization. Useful info to impress people with at your next Cheese and Wine party.

Generic programming

This style of programming that the C++ templates offer is known as generic programming. Another style you may have heard of is object-oriented programming. A template is given the type of list, and it counts it, regardless of whether it is the list of names, bank accounts, or famous dates. There has been a great deal of interest in this type of programming since, well C++ introduced templates. In the past few years both Java and C# have introduced something similar to templates called generics.

The Standard Template Library

Unlike most major languages which were released after C++ like Perl and Java, C++ only had a small library which was similar to C's rather spartan standard library. This just provided the basic file handling routines. The Standard Template Library (STL) was written externally by researchers interested in generic programming. It was made available on the internet in 1994 for C++ programmers to use. In 1998 the STL was included as part of the C++ Standard Library. As the STL is a major component of the Standard Library, many refer to the Standard Library as the STL.

C++ is powerful, fast, and challenging

Finally standardised in 1998, with many features added during it's development, it's a large language and with it's complex and large grammar it is considered a difficult language to master. C++ was developed to enhance C to make writing large scale software development more feasible. It became hugely popular due to it's excellent performance, good range of programming features and also due to it's connection with C.

During the 1990s C++ was the most popular programming language for software development. It is still in widespread use today. As computing power increases over time, the performance advantage of C++ becomes less important. For many purposes, newer and easier to program languages such as Java and Python are more appropriate. It is still widely used for new projects in embedded software, systems software, utility software and games programming.

Comments

Post a comment

Name
Comments
Just Curious Guides to Technology