| Previous | Table of Contents | Next |
Welcome to Teach Yourself C++ in 24 Hours! In this very first hour you will learn:
C++ is the development language of choice for the majority of professional programmers because it offers fast, small programs developed in a robust and portable environment. Todays C++ tools make creating complex and powerful commercial applications a pretty straightforward exercise, but to get the most out of C++ you need to learn quite a bit about this powerful language.
C++ is a relatively new language. Of course, programming itself is only about 40 years old. During that time computer languages have undergone a dramatic evolution.
Early on, programmers worked with the most primitive computer instructions: machine language. These instructions were represented by long strings of ones and zeroes. Soon, assemblers were invented that could map machine instructions to human-readable and manageable mnemonics, such as ADD and MOV.
![]() | In time, higher-level languages evolved, such as BASIC and COBOL. These languages let people work with something approximating words and sentences, such as Let I = 100. These instructions were translated back into machine language by interpreters and compilers. An interpreter, like BASIC, translates a program as it reads it, turning the programmers program instructions or code directly into actions. |
![]() | New compilers translate the code into what is called object code. The first step in this transformation is called compiling. A compiler produces an object file. The second step is called linking. A linker transforms the object file into an executable program. An executable program is one that runs on your operating system. |
Because interpreters read the code as it is written and execute the code on the spot, they are easy for the programmer to work with. Compilers introduce the inconvenient extra steps of compiling and linking the code. On the other hand, compilers produce a program that is very fast each time it is run.
For many years, the principal goal of computer programmers was to write short pieces of code that would execute quickly. The program needed to be small because memory was expensive, and it needed to be fast because processing power was also expensive. As computers have become smaller, cheaper, and faster, and as the cost of memory has fallen, these priorities have changed. Today the cost of a programmers time far outweighs the cost of most of the computers in use by businesses. Well-written, easy-to-maintain code is at a premium. Easy-to-maintain means that as business requirements change, the program can be extended and enhanced without great expense.
![]() | In procedural programming, programs are thought of as a series of actions performed on a set of data. Structured programming was invented to provide a systematic approach to organizing these procedures, and to managing large amounts of data. |
The principle idea behind structured programming is as simple as the idea of divide and conquer. Any task that is too complex to be described is broken down into a set of smaller component tasks, until the tasks are small and self-contained enough that they are easily understood.
As an example, computing the average salary of every employee of a company is a rather complex task. You can, however, break it down into these subtasks:
Totaling the salaries can be broken down into:
In turn, obtaining each employees record can be broken down into:
Structured programming remains an enormously successful approach for dealing with complex problems.
Yet, there are problems. The separation of data from the tasks that manipulate the data becomes harder and harder to comprehend and maintain as the amount of data grows. The more things you want to do with that data, the more confusing it becomes.
Procedural programmers find themselves constantly reinventing new solutions to old problems. This is often called reinventing the wheel and is the opposite of reusability. The idea behind reusability is to build components that have known properties and then to be able to plug them into your program as you need them. This is modeled after the hardware worldwhen an engineer needs a new transistor she doesnt usually invent one; she goes to the big bin of transistors and finds one that works for what she needs or perhaps modifies it. Until object-oriented programming, there was no similar option for a software engineer.
![]() | The essence of object-oriented programming is to treat data and the procedures that act upon the data as a single objecta self-contained entity with an identity and certain characteristics of its own. |
| Previous | Table of Contents | Next |