Lecture 2: Computers


What is a computer? According to the Columbia Encyclopedia it is
"a device capable of performing a series of arithmetic or logical operations. A computer is distinguished from a calculating machine, such as an electronic calculator, by being able to store a computer program (so that it can repeat its operations and make logical decisions), by the number and complexity of the operations it can perform, and by its ability to process, store, and retrieve data without human intervention."

Existem vários tipos de computadores. Today, when we say 'computer' we mean a digital computer. Historically, there also existed mechanical and analog (electrical) computers.
The first mechanical computer was designed by Charles Babbage in the beginning of the 19th century (around 1815)!  For this reason, Babbage is often called "The father of computing". Famous is also his Difference Engine. If you want to know more about Charles Babbage, click here.
The first electronic computer, processing data in digital format was called ENIAC just before the second word war (1939). The first commercially available computer was the UNIVAC (in 1951). At that time it was thought that a handful of computers, distributed around the world, would be sufficient to take care of all computer calculations. Nowadays, nearly everybody in the western world has a computer at home, much more powerful than those first computers.

Computers are categorized by both size and the number of people who can use them at the same time:

Supercomputers sophisticated machines designed to perform complex calculations at maximum speed; they are used to model very large dynamic systems, such as weather patterns.
An example is the Cray SV2 (see picture), which is the size of an average living room.
Mainframes the largest and most powerful general-purpose systems, are designed to meet the computing needs of a large organization by serving hundreds of computer terminals at the same time.
Imagine insurance companies with all their documents internally shared over a network. All employees can retrieve and edit the same data.
Minicomputers though somewhat smaller, also are multiuser computers, intended to meet the needs of a small company by serving up to a hundred terminals.
Microcomputers computers powered by a microprocessor, are subdivided into personal computers and workstations.
Personal computers are what most people have at home

Examples:
IBM PC and compatibles with a microprocessor like the Intel Pentium IV, 1.5 Ghz. Portable computers are a portable variant of microcomputers
Apple Macintosh encorporating the Motorola processor family.

Processors Many home appliances, like washing machines and ovens, contain a small processor that is controlling the machine. These are very small computers that have been programmed in the factory in hardware and cannot be programmed by the user. As such, they can probably not be considered computers, but are still important to mention. Some more-advanced home appliances, like satellite receivers or home-cinema equipment, are running quite sophisticated programs which follow the rules which will be presented in this lecture.

Note: with the speed the technology is advancing we can say that "the supercomputers of today are the (personal) microcomputers of tomorrow"


Hardware vs. software

Two important things to distinguish are hardware and software. Hardware is everything that you can feel and touch. Sofware is the programs that are running on the hardware. Example are given below.

Every working computer consists at least of the following:
1) A processor
2) Memory to store the program
3) An output device
4) A program running
Most computers also have
5) An input device, to either change the program running, enter new data to be processed, or control the processes running.

Let's take a look of things we can find in a computer system:

Table: hardware elements

Mouse input device to control the processes of the computer
CPU processor Central Processing Unit
is what is doing all the work. Calculating, controlling data flow, etc.
Joystick
input device input data to a game
Keyboard input device to give instructions to the computer
or enter data to be processed
Memory
storage store program and data to be processed
Monitor
output device show results of processes
Printer
output device show results of processes
Modem input/output MOdulator-DEModulator
communicate with other computers over a telephone line
Network card input/output communicate with other computers over a high bandwidth network
Harddisk/floppy disk
storage store data or programs in non-volatile format (data will stay when
the computer is switched off)
CD-ROM input load programs or data into the computer memory
Sound card
output play music or other sounds
Scanner input scan an image

Physical and logical layers of a computer

At the lowest level we can determine the level of Physics. Electrons (and holes) are responsible for the electrical conduction of the material. The materials used in computers is called semiconductors, meaning that they have a resistance in-between metals (like copper and gold) and isolators (like glass and plastic).
 

At the next level we find Electronics. Electronics connect materials with different properties and the resulting electronic components show remarkable and useful behavior. Note the diode which conducts current only in one direction, or the transistor, whose conductivity is controlled by an external voltage.
The picture shows the first
transistor, as invented at Bell Labs in 1947.

Next we find the level of Digital Electronics. This involves so-called gates: OR, NOR, AND, NAND, XOR, to name a few. Such gates are made up of basic electronic components like transistors. Gates are the cornerstone of digital computers. We have to remember that all calculations of computers at the end are done on this level. When we add 2+2, somewhere in the computer gates are switching and are performing calculation like  "1 OR 1 = 1".
Another important component of digital electronics is memory. These are also made up of transistors (and capacitors in case of dynamic RAM) and can temporarily store information.
 
Moores law for transitor
                density

The next level is that of Integrated Circuits. In these circuits, millions and millions of gates are connected and this allows for complex programs to run.
In the years since the first integrated circuits, the number of transistors on a single IC has been doubling every two years, approximately. This is called Moore's law and is still valid, although the physical limits seem to be in sight. See the picture on the left.

To make a popular comparison. If the same industrial advance had been made in the car industry, a modern car would be able to run at 5 million km/h, consume 1 drop of petrol per 100.000 km and could seat about 10 thousand people

.

At the next level the real programming starts. We start with binary programs, or (in readable format) Micro-assembler. This is directly programming the processor: put address xxx in address register, enable addressing lines, wait xx ns, add register X to register Y, etc. ("registers" are small memory units inside the processor)

The next level consists of Machine language. This is directly programming the processor with binary code like
 101000100000101000
which might mean: put the contents of address 0000101000 into the A register. Such code is nearly impossible for humans to read. Therefore, very rapidly macro-assembler were invented. When a program is executed, this code is (without further translation) directly put in the memory and executed. Files with extensions like ".exe" and ".com" in MS-DOS and Windows are of this type.

For the next level, which already starts looking like real programming, we have Macro-assembler. In this level we instruct the processor to execute the small programs written in microassembler. These are equal to machine language, but in a more readable format and with the first hints of higher level programming (for instance "labels" and "variables"). In macro-assembler we write commands like
 ADDA $2050
which might mean "add the contents of memory at address $2050 to register A" and which is translated by the assembler into machine code.

At the next level we finally have our modern Programming languages. These languages are often called "fourth generation languages", because they evolved from earlier languages such as assembler, etc. Many of these programming languages were invented during the 1960s and and 1970s. For every application there exists a programming language. In 1995 there existed about 2500 different programming languages. (for people interested, see http://people.ku.edu/~nkinners/LangList/Extras/langlist.htm).
For professional programmers there is C and C++, for simple applications, there is BASIC. For educational purposes PASCAL was invented, especially to teach the ideas of programming.
Examples:

 BASIC   IF A=20 THEN PRINT"Hello World" 
 PASCAL   if (a=20) then writeln('Hello World');
 C  if (a==20) printf("Hello world\n");
 FORTRAN   IF (A .EQ. 20) PRINT ,'Hello World'

Lately new generations of programming languages are evolving. All of them involve the concept of Object-oriented programming, a concept that we will not use in our lectures, but has become indispensable in modern program environments. We might call this "fifth generation languages"

Modern programming languages are very flexible. We can write a variety of applications in the languages. We might, for instance, write a program that simulates the workings of a diode, or calculate a transistor at the physical level. Then we are full-circle; we will use the computer to make the basic components - and thus the computer - better and faster.
Also, bear in mind, that if we write in Pascal
  writeln('Hello world');
and run the program, we are, in fact, controlling the flow of electrons on the lowest levels. This might give you a good feeling of control .....


Compilers

As said before, modern programming languages have to be translated from a form that the user understands to a form that the computer understands. When we write
  writeln('Benfica - Sporting   3 - 0');
This has to be translated into
  MOVAI $0102       ; load 'B' into A register
  MOVAO $1245     ; move contents of register to Video Card
or, one level deeper
  0011011100011111110001111010001111
For this purpose exist compilers. They translate text that is readable to humans into something that is executable for the computer. When we start with a file containing our program myprogram.pas, we translate this with a compiler which will generate a file called
  myprogram.exe
which we can call with
 myprogram
and the following output will appear on the screen when everything goes correct
 Benfica - Sporting   3 - 0

In most modern version of a programming language we will work within a so-called IDE (integrated development environment), which means that we can write the program and with a single key press we can compile the program, see the errors of our writing, and, in case there were no errors during compilation, execute the program and see the results. Such environments greatly speed up the development of software, but we should not forget that in fact a compiler is translating the program for us.

We will discuss compilers later and the use of compilers will also be explained in the practical lessons.


Operating Systems

Operating systems are programs that are constantly running on our computer and are interpreting the commands we give it. For instance, when we want to 'run' our program, we can write its name or click on its icon, or something like that. The operating system will then
  1) load our program from harddisk into memory
  2) start executing it
When our program is finished it is normally removed from the memory again, but the operating system will continue running, waiting for our next instruction. In fact, a computer left alone is doing nothing but checking if we already typed something or clicked on something. What a waste of energy .....

The most famous operating system was probably MS-DOS by Microsoft. This was a command-line operating system, meaning that you had to type-in your instructions to the computer using a keyboard. For example
  DIR C:\
Later, a graphical interface was added to MS-DOS and it was called Windows. Underlying it, was still the same MS-DOS command line operating system, but our mouse-clicks on  icons and objects was translated into commands. We might click on a 'folder' and see its contents. Clicking on a folder would then be equal to typing DIR, with the output presented in graphical format.
Over the years, Windows has become more advanced and nowadays it is a multitasking operating system (meaning that more than one program can run at the same time) and most people in the world are using it.
Because of the monopoly that Microsoft has, the 27% of the shares that co-founder Bill Gates has in this company had a value of $20 billion (20.000.000.000 dollars) in 1995. By 2000 it had risen to $65 billion. Note, this is about $10 for every person on earth, be it an American or a Chinese in whatever remote village in China.
Alternatives to Windows are Unix/Linux, which has the advantage that it is for free and MacOS, which runs on Macintosh computer, as described above.
 
 


Quick test:

To test your knowledge of what you have learned in this lesson, click here for an on-line test. Note that this NOT the form the final test takes!


Peter Stallinga, Universidade do Algarve, 6 fevereiro 2002