Chapter 1: Solving problems with computers
What is a computer?
Hardware: you can physically check; CPU, memory, hard disk, floppy disk, monitor, printer,
Software: instructions to the computer, without programs a computer is an empty machine- computers
do not understand human languages
-Computers execute instructions to process data.
CPU: central processing unit which are built as a single microprocessor chip. Each chip is associated with
a set of instructions (Machine Code) which it can execute.
Binary Bit Patterns: strings of 0 and 1’s, like a switch. Each instruction and the data are stored as binary
patterns; any given computer can only execute instructions in the machine code language of its
A machine code computer program consists of binary codes for instructions. The program can
be stored on a disk. To execute the program, it is loaded from the disk into the computer’s
internal memory, then the instructions are fetched one by one by the microprocessor(CPU) and
Disadvantages of Machine Codes: time consuming, meaningless to human readers, not portable
Assembler Language: little words (mnemonics) are used, each of which corresponds to one of the
machine code instructions. Data can be represented using decimal numbers instead of binary. Example,
load number 5 = LD 5 instead of 00100010010.
A program named an Assembler is required to TRANSLATE an assembler language program into
Disadvantages: still not portable and obsolete
High Level Languages: 3 generation programming languages that were more abstract, problem
oriented instructions. Examples: C++, Java, Modula-2/3, Simula, Pascal, Ada, Algol, FORTRAN, Cobol
Made programming less error prone and more productive but they could not be executed on a
computer, they had to be stored as character codes, then translated into the machine code for
the required processor
A program called the Compiler, checks for any syntax (spelling and grammar) of the high level
language and reports any errors. It then creates a machine code version of the high level
program. Once this is done, the machine code may be executed on the host machine without
the compiler being present
Compilers are need to port source programs to any machine. Recompiling is essential for
different platforms. Computers are networked to work together.
A program in high level language is called a source program, computers cannot understand
source programs, therefore a compiler translates the source program (linked with supporting
Bootstrapping: in order to run on a computer, a compiler must be written in machine code. It’s
hard to write a compiler in low level language there a compiler is written in high level.
Therefore, we need to compile the complier which someone has to make a compiler written in
machine code first.Java
Developed by Sun Microsystem Inc, made in 1991 by James Gosling and Bill Joy
Java program is just a text file, it contains letters, numbers, and symbols= source code file
In order to create a program, the java complier will require the filename of the java source
(which would be made in Notepad) to end in “.java”. The program text is then fed into the Java
complier, if there is no errors the output will be a file containing the compiled byte code
programmed, ready to run. To run the program, the “.class” file is fed into the run time
Java was designed to run object programs on any platform. With java, you write the program
once and compile the source program into a special type of obje