![]()  | 
            
              Lecture 2: Computers | 
            
What
    is
    a computer? According to the Columbia Encyclopedia it is
    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: 
 
  | 
          |||||
| 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"
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.
    
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 | 
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.  | 
          
            
  | 
        
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.
      
       
      
 
              
  | 
            
               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
      .....
    
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.
      
    
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.