You are on page 1of 42

Lecture 1: Computer Structure,

Classification of Computer
Programming Languages

Prof. Carolina Pea-Ortega

Universidad de la Salle

Outline
Computer Structure
Software: Operating System and Application Software
Programming Languages
Program Development Life Cycle

Computer structure

What is a Computer?

A computer is an
electronic device that
manipulates information, or
data. It can store,
retrieve, and process data.

Computer Hardware
The physical components of a computer.
Most computers have six basic components:
Main memory
Central processing unit (CPU)

The arithmetic/logic unit (ALU)


The control unit

Input/output devices
Auxiliary storage devices

Basic Components of a Computer


Peripherals
Input Device

Output Device

Auxiliary
Storage
Device

Central Processing Unit ( CPU )


Control Unit
Arithmetic Logic Unit

Memory Unit ( RAM & Registers )

Central Processing Unit (CPU)

The part of the computer that


executes
the
instructions
(program) stored in memory;
made up of the arithmetic/logic
unit and the control unit.

Central Processing Unit (CPU)


The arithmetic/logic unit (ALU) performs
arithmetic
operations
(addition,
subtraction,
multiplication, and division) and logical operations
(comparing two values).
The control unit controls the actions of the other
components so that program instructions are
executed in the correct order.

Main Memory
Commonly known as random access memory (RAM)
Holds instructions and data needed for programs that
are currently running
RAM is usually a volatile type of memory
Used as temporary storage

Secondary Storage

A nonvolatile storage medium


Hard disk drives are most common
Records data magnetically on a circular disk
Provides fast access to large amounts of data
Optical devices store data on CDs as pits
USB flash memory devices
High capacity device plugs into USB port
Portable, reliable, and fits easily in a pocket

10

Input/output (I/O) Devices

The parts of the computer that accept data to be


processed (input) and present the results of that
processing (output).
Input devices: any type of device that provides data
to a computer from the outside world. Example:
keyboard, mouse and scanner.
Output devices: any type of device that provides
data from a computer to the outside world. Example:
Monitor (display screen) and printer.

11

Software

The programs that run on a computer


Two major categories:
Operating systems
Controls the processes within the computer
Manages the computer's hardware devices
Application Software
Solve problems or perform tasks needed by
users
Examples include word processing, spreadsheets,
games, Internet browsers, playing music, etc)
Each program is referred to as an application
12

Concepts

Computer programming: The process of planning


a sequence of steps for a computer to follow.
Algorithm: A step-by-step procedure for solving a
problem in a finite amount of time.
Computer program: A sequence of instructions to
be performed by a computer.
Programming language: A set of rules, symbols,
and special words used to construct a computer
program.

13

Classification of computer
programming languages

14

Programming Languages

The steps in our algorithm must be stated in a form


the computer understands
The CPU processes instructions as a series of 1s and
0s called machine language
Machine language: The language, made up of
binary-coded instructions (strings of 0s and 1s), that
is used directly by the computer. It is no portable, and
it runs only on specific type of computer.

15

Programming Languages

Assembly language: It is based on mnemonics that


symbolize processing steps (instructions), processor
registers, memory locations, and other language
features.
Use symbols instead of binary digits to describe fields
of instructions.

ADDI R4,R2,21

16

ADDI
R4
R2
21
10101100100000100000000000010101

Assembler Program

A utility program called an assembler is used to


translate assembly language statements into the
target computer's machine code.
Source program: A program written in assembly
language.
Object program: The machine language version of
a source program.
Source
Program
(Assembly)
17

ASSEMBLER

Object
Program

Levels of Programming Languages

The levels of programming languages are:

Low-level language

High-level language

18

Levels of Programming Languages

Low-Level Language: A computer language that


deals with hardware registers by name; also known as
assembly language.
A program written in a low-level language can be
used only on a computer system that uses one type
of main processor (or possibly a member of a family
of processors).
Low-level programming wastes effort in coding a
solution rather than solving a problem.
Difficult to build and maintain large programs.
19

Levels of Programming Languages

High-Level Language: High-level programming


languages allow the specification of a problem
solution in terms closer to those used by human
beings.
These languages were designed to make
programming far easier, less error-prone and to
remove the programmer from having to know the
details of the internal structure of a particular
computer.
High-Level languages are portable, and they require a
compiler.
20

Compiler and Interpreter Languages

In addition to the distinction between high-level and


low-level languages, there is a further distinction
between compiler languages and interpreter
languages:
Compiler Languages: are the high-level equivalent
of assembly language. Each instruction in the compiler
language can correspond to many machine
instructions.

21

Compiler Languages

Once the program has been


written, it is translated to the
equivalent machine code by a
program called a compiler. Once the
program has been compiled, the
resulting machine code is saved
separately, and can be run on its
own at any time.

22

Source
Program

COMPILER
Object
Program

Interpreter Languages

23

An interpreter language, like a


compiler language, is considered
to be high level. However, it
operates in a totally different
manner from a compiler language.
Rather, the interpreter program
resides in memory, and directly
executes the high-level program
without preliminary translation to
machine code.

Source
Program

INTERPRETER
translation and
execution line
by line

Interpreter Languages

This use of an interpreter program to directly


execute the user's program has both advantages and
disadvantages. The primary advantage is that you can
run the program to test its operation, make a few
changes, and run it again directly.
In addition, because the interpreter has to scan the
user's program one line at a time and execute
internal portions of itself in response, execution of
an interpreted program is much slower than
for a compiled program.
24

Common Programming Languages

25

Python Interpreter language


Matlab Interpreter language
Java Compiler language
C Compiler language
C++ - Compiler language
Visual Basic Compiler and Interpreter language

26

Code Examples
C
#include <stdio.h>
void main() {
printf("Hello, World!\n");
}

Machine Code

c7 3c 2a 3c 2a 2b 2a 5c 3c 28 5c 2a 2b 2a 5c 3c
28 5c 2a 2b 2a 5c 3c 28 5c 2a 2b 2a 5c 3c 28 5c
2a 2b 2a 5c 3c 28 5c 2a 2b 2a 5c 3c 28 5c 2a 2b
2a 5c 3c 28 5c 2a 2b 2a 5c 3c 28 5c 2a 2b 2a 5c
3c 28 5c 2a 2b 2a 5c 3c 28 5c 2a 2b 2a 5c 3c 28

26

C++

#include <iostream>
void main(){
cout << "Hello, World!\n;
}

Python
print "Hello, World!"

Program Development Life Cycle

27

Program Development Life Cycle

The basic set of procedures that are followed by


various organizations in their program development
methods are as follows:
1.
2.
3.
4.
5.

6.

28

Problem Definition
Algorithm Design
Coding
Debugging and Testing
Documentation
Maintenance

Program Development Life Cycle

Stages of
Program
Development
Life Cycle

Maintenance
Documentation

Problem Definition
and Design

1
Time

29

Phase 1: Problem Definition and Design


Debugging
and Testing
Steps of
Problem
Definition
and Design

Coding
Problem
Definition

Program Design

Time

30

Phase 1: Problem Definition and Design


Step 1: Problem Definition
This stage is the formal definition of the task. It
includes the specification of inputs and outputs
processing requirements, system constraints, and
error handling methods.
This step is very critical for the completion of
a satisfactory program. It is impossible to solve a
problem by using a computer, without a clear
understanding and identification of the problem.
Inadequate identification of problem leads to poor
performance of the system.
31

Phase 1: Problem Definition and Design


Step 2: Algorithm Design
Once the problem has been identified, the next stage
is the program design. The programmer must
decide, prior to writing his program, exactly
which steps the computer should take to solve
an identified problem.
Such a functional description of the task is either
called an algorithm or results in a diagram called
flowchart.

32

Phase 1: Problem Definition and Design

The techniques that are useful in program design include:

Modular Programming: A method in which long


programs are divided into smaller programs or
modulates that can be designed, coded and debugged
separately with a minimum amount of interaction.
Main
Program
Module 1
Module 11
33

Module 2
Module 21

Module 22

Phase 1: Problem Definition and Design

34

Top-Down Design: A method in which the


overall task is first defined in terms of generalized
sub-tasks that, in turn, are subsequently further
defined. The process continues downward until
the sub-tasks are defined in a form suitable for
execution by the computer.

Phase 1: Problem Definition and Design


Step 3: Coding
The third step is the process of transforming the
program logic design documents into a computer
language format.
This stage translates the program design into
computer instructions. These instructions are the
actual program or the software product.
During this step the programmer eliminates all the
syntax and formal errors from the program and
all logic errors are detected and resolved during this
process.
35

Phase 1: Problem Definition and Design


Step 4: Debugging and Testing
Debugging: This stage is the discovery and
correction of programming errors. Few programs
run correctly the first time, so debugging is an
important and time consuming stage of software
development.

36

Phase 1: Problem Definition and Design

37

Testing: This stage is the validation of the program.


Testing ensures that the program performs
correctly the required tasks. Program testing and
program debugging are closely related. Testing is
essentially a later stage of debugging in which the
program is validated by trying it on a suitable set of
cases.
Testing may reveal errors, but does not guarantee
the absence of errors.

Phase 1: Problem Definition and Design

Programming theorists often refer to program


debugging and testing as verification and validation,
respectively. Verification ensures that the
program does what the programmer intends
to do. Validation ensures that the program
gives the correct results for a set of test data.

38

Phase 2: Documentation

This stage is the documentation of the program so that


those who use and maintain it, can understand it, so that
the program can be extended to further applications. Yet
proper documentation is not only useful in the testing
and debugging stages, it is also essential in the
maintenance and redesign stages.
A properly documented program can be easily reused
when needed; an undocumented program usually requires
so much extra work that the programmer might as well
start from scratch.

39

Phase 2: Documentation

Among the techniques commonly used in


documentation are flowcharts, comments, memory
maps, parameter and definition lists, and program
library forms.
Documentation is a time consuming task that the
programmer performs simultaneously with the design,
coding, debugging and testing stages of software
development.

40

Phase 3: Maintenance

This stage is the updating and correcting of the


program to account for changing conditions or field
experience.
In order to reduce the costs and the time spent on
maintenance, we can use the following steps:
Clarity and readability of code.
Structured code.
Modularity.
Debugging and testing.
Documentation.
41

References

Programming in C++, Nell Dale and Chip Weems.


Chapter 1.
C++ for Engineers and Scientists, Gary J. Bronson.
Chapter 1.

42

You might also like