system call diagrams
A BareMetal Image

C++ is a powerful mid-level programming language developed in the early 1980s by a danish programmer, Bjarne Stroustrup, in the Bell Laboratories, New Jersey, USA. To better understand the language philosophy and design of C++, read brief history of the language.

History of the C++ language

Languages are developed every few years (at least for consequential languages), there are two main reasons believed to be causing the change:

  • Change in environment on which the languages execute.
  • Need to implement refinement in the art of programming.


C++ is a direct descendant of C and like its predecessors, was conceived due to the above reasons (tapping both Simula’s facilities for organizing code and C ability to ability to write efficient close to hardware code), there was a need for relatively easy to write/understand language which will be also fast in the existing architectures.

Before C, there were computer languages like COBOL and FORTRAN which were not designed around structured principles, they relied upon goto statements as primary control structure. This resulted in the infamous spaghetti code which are very hard to wrap your mind around especially when they constitute a very large code base.

C language was developed in 1972 by Dennis Ritchie and Brian Kernighan to solve the spaghetti code problem by use of functions, structures and better control structures among other things. The resulting product was a structured, high-level language with ability to replace assembly code in system programming. Since these techniques have been incorporated in almost all new languages, C has been considered to have marked the beginning of modern age of computer programming languages. The language also was touted as a “programmers’ language” because it was developed by people in the field like most of the languages which came thereafter.

In the late 1970s, Bjarne, started to work on a way C could model real-world object to improve code maintainability and ease of use. He extended C language to enable object-oriented (OOP) programming and called the product “C with Classes”. It was later renamed C++ in 1983 because it included everything in C and it added OOP concepts.

Modern C++

C++ is not a dormant language (lazily admiring its success from the beaches of Mombassa), it continually integrates new features and new ways of doing things. In 2011, several new features were added to the C++ language; lambda expressions, auto for type deduction, range-based for loops among others. Low-level constructs were also replaced by containers, smart pointers, move semantics, passing objects by values among others. The result of this continuous refinement is the modern days robust and yet very fast C++ language, modern C++.

Object-Oriented Programming Concepts

Object-Oriented Programming is a programming paradigm which lays emphasis on the object as the basis of programming. Unlike procedural programming which answers the question “what is happening”, OOP answers the question “what is being affected”. Here are concepts which support this paradigm.

1. Abstraction

Abstraction is a technique of hiding the implementation details of an object while revealing interfaces for use. A car is a classical example, most drivers do not know what’s hidden below their sits but can use the car efficiently due to the interfaces provided like steering wheel, accelerator and so on. In general people use abstraction to manage complexity.

2. Encapsulation

Encapsulation is an OOP concept that specifies that data and methods working on the data should be enclosed together to form a single unit. This magically increases code maintainability because all members of a class are relatively close to each other. It also regulates access such that only specified interfaces can be used to access specified member data ensuring security.

3. Inheritance

Inheritance is the process by which one object acquires the properties of another object. Real-world objects extensively exhibit inheritance. Consider a student, a student is a person , a person is a mammal, a mammal is an animal. This means that all characteristics of an animal are present in a person, all characteristics of a person is present in a student and so on. Inheritance is a key concept that lets object-oriented programs grow in complexity linearly rather than geometrically.

4. Polymorphism

Polymorphism in OOP is a concept that describes dynamic objects and methods behavior based on context. In real-world, dogs can smell all kinds of smells and they elicit distinct behavior. If the dog smells an intruder, it runs after it. If the same dog smells food, it runs to its bowl. This ability to have one interface and let the system determine the right action is extensively used in OOP. For example, a program may have several functions with same name, the one which will be called depend on the arguments supplied.

YOU MIGHT ALSO LIKE


Common Application of C++

C++ is a general purpose language with leading focus on the task to be done. C++ language delivers speed, efficiency (in computing resource usage) and elegance. Due to these and many other benefits, C++ language is used in:

  • Operating System development.
  • Game engines and games.
  • GUI-intensive applications.
  • Browsers
  • Many other software demanding speed, resource efficiency and scalability.

Reasons for Using C++

Efficient and Fast

Current computers do not have unlimited resources. Users also do not have unlimited patience. For a program to be successful it therefore has to get the job done with minimal resources and in reasonable amount of time. C++ has structures like standard template library, STL, which are highly optimized to run fast using minimal resources. Few modern day languages can beat C++ when it comes to speed, efficiency and control.

Embedded Systems

C++ is in the elevators, microwaves, sensors, routers and all kinds of embedded systems because of the control it gives to the programmer, how efficiently it uses the highly limited resources and the speed it guarantees.

Big Projects

C++ is was built for scalability. All the OOP concepts contribute in scalability generally because they imitate how human view objects and perform tasks. Speed, efficiency and scalability is unbeatable combo when it comes to large-scale projects.

Starting point in programming

Expert in the field and lectures argue that C++ is the best starting point for a smooth early career in software engineering. Software engineering demands that engineers understand all the reason behind a behavior or feature. C++ language is designed to elicit thoughts about memory, processors and resource management. This enables learners to appreciate other languages quickly. Another reason is that C++ is closer to both C and Java. Most senior programmers effortlessly switch between these.