Part I
Computing Essentials
CHAPTER 1
Computers and Programming Languages: An Introduction
This chapter defines programming and programming languages for the reader with a summary of modern computing as a backdrop. It goes further to explain the role of numbers in computers and potential problems in their use.
Computers are incredibly fast, accurate, and stupid. Humans beings are incredibly slow, inaccurate, and brilliant. Together they are powerful beyond imagination.
Leo Cherne 1 (1969)
1.1 Early History of Computing
It is hard to believe that only about 100 years ago, there were no computers. Computers used to be humans who were trained to do quite complex calculations using only their minds and some mechanical aids. Have a look at Figure 1.1. The painting 2 depicts an ordinary school in rural Russia. It might be hard to see, but pupils are looking for the result of the following expression inscribed on the blackboard:
| (1.1) |
Figure 1.1 On the left is the painting by Nikolay Bogdanov-Belsky, dated 1895: ā Mental Arithmetic. In the Public School of S.Rachinskyā . An enlarged portion of the blackboard is shown on the right.
There were aids: abaci, sliding rulers, pre-calculated tables of functions (logarithms, trigonometric functions, exponents, . . .), and mechanical calculators, which start to show up at the end of the nineteenth century. These mechanical aids were not programmable; they were designed to do a fixed subset of elementary calculations. Instead, you would ā programā , that is, ask to do a complex problem, a human. 3
1.2 Modern Computers
We can probably attribute the title of the very first computer, the direct ancestor of modern ones, to ENIAC (Electronic Numerical Integrator And Computer), which was constructed in 1946. Here are some of its specifications:
⢠Weight: 30 tons
⢠Cost: $500,000 ($6,000,000 adjusted for inflation)
⢠Power consumption: 150 kW (averaged consumption of 500 households)
With all its might, ENIAC could do the following in 1s: 5000 additions, 357 multiplications, or 38 divisions. Modern computer speed is measured in FLOPS (the number of floating-point operations per second). So we see that ENIAC was able to do about 100 FLOPS, while the authorā s several-years-old desktop computer can do about 50 Mega FLOPS. A typical mobile phone outperforms ENIAC by many orders of magnitude.
1.2.1 Common features of a modern computer
A modern computer typically has the following features. It has one or more central processing units (CPU), memory, which holds data and programs, and input and output interfaces (keyboards, hard drives, displays, printers, . . .). A typical computer uses the binary system internally....