Review: computer memory

  • Recall that the computer memory consists of a series of electical switches and each switch can store/remember one of the value of 0 or 1:

            

  • We have also learned that:

      • The computer memory contains the computer program !     

  • Therefore:  

    • A computer program is a bunch of binary numbers !!

How people program a computer around 1945

  • Programmers would set switches to on/off to write out the computer instruction in binary:

  • Programming was a very tedious task in the pioneer days !

How people program a computer around 1950

  • We invented the assembler programming language which are mnemonics for each binary machine instruction:

  • A (simple) translation program can an assembler translates an assembler program to binary machine code

How people program a computer around 1957

  • The first programming language (Fortran) was invented:

  • A complex translation program can an compiler translates a Fortran program to assembler code

Demo how the compiler translates a C program into assembler code

  • I don't have a Fortran compiler

  • I do have a C compiler

  • Here's a small C program:

      int a, b, c;
      
      int main()
      {
         c = a + b;             
      }

  • I will show you the output (= assembler program) generated by the C compiler

DEMO: demo/01-basics/01-compiler/assembler.c (in folder ~/c/OutSchool/CS/AP-CS/)

Programming in Java

  • A Java program needs to be translated ("compiled") before you can run the program:

  • The Java Compiler program is called javac

  • But we will be using an "Integrated Development Environment" (IDE) called BlueJ that make compiling and running Java programs very easy

DEMO: demo/01-basics/01-compiler/hello.java (in folder ~/c/OutSchool/CS/AP-CS/)