Download CLASSIFICATION OF LANGUAGES BY GENERATION

Document related concepts
no text concepts found
Transcript
MODULE 3 : CLASSIFICATION OF COMPUTER
PROGRAMMING LANGUAGES - Overview
• Problem solving through computer programming is
strongly dictated by the nature of the problem and the
architecture of the computer system. These two forces
have, over the years brought about many programming
languages used in communicating with the computer
system in solving problems. The languages can be
classified based on the computer architecture, the
historical trend or the principles and methods used in the
problem solving effort.
• Designing a solution to a specific problem depends on
the logic used. The type of logic will depend on the
design and analysis. This will determine the paradigms to
be deployed (object oriented, procedure, functional etc)
Mr. Joseph Ecklu (DCS)
1
Session Objectives
At the end of the session, the student will
– Be able to identify the three main classification of
computer language
– Be able to identify languages based on the
computer architecture
– Be able to identify languages based on historical
generation
– Be able to identify languages based on
characteristics of the language - paradigm
Mr. Joseph Ecklu (DCS)
2
Reading List
• Programming Language Essentials by Bal H.E. and
Grune D.(Chapters 2, 3, 4 , 5 and 6 )
• C.S. French “Computer Science” Fifth Edition (
Chapters 27 , 28)
• Foundations of Computer Science by Forouzan B. and
Mosharraf F (Chapter 9)
• Chp 1 of C++ Programming , Malik, D.S.
Mr. Joseph Ecklu (DCS)
3
Session Outline
The key topics to be covered in the session are as
follows:
Topic one: Classification Of Computer
Programming Languages
Topic Two: Classification Of Languages Based On
Level /Degree Of Abstraction From Machine
Topic Three: Programming Paradigms
Mr. Joseph Eklu (DCS)
Slide 4
Topic One
CLASSIFICATION OF COMPUTER
PROGRAMMING LANGUAGES
Mr. Joseph Ecklu (DCS)
Slide 5
CLASSIFICATION OF COMPUTER
PROGRAMMING LANGUAGES
Computer Programming Languages have been classified
based on various factors
• FACTORS
– GENERATION
– LEVEL / DEGREE OF ABSTRACTION FROM MACHINE
– PARADIGM
Mr. Joseph Ecklu (DCS)
6
CLASSIFICATION OF LANGUAGES BY
GENERATION
• Languages have traditionally been classified in
generations
Mr. Joseph Ecklu (DCS)
7
GENERATION OF LANGUAGES
• Generations
–
–
–
–
–
1st Generation machine language
2nd Generation assembly language
3rd Generation procedural languages
4th Generation application languages
5th Generation Artificial Intelligence
technique, inference
languages
– 6th Generation neural languages
Mr. Joseph Ecklu (DCS)
8
1st Generation
• Machine languages
Prelingual stage:
machines were not programmed exclusively by internal
programs
console buttons, switches and plugs were used and
they influenced the internal program such that they
were considered as part of the program
Mr. Joseph Ecklu (DCS)
9
2nd Generation
• Assembly languages
Exploiting machine power ( 1950s)
Computers were programmed in assembly language
Programming mainly consisted of converting numerical
formulas to assembler instructions
Low level programming languages emerged
Mr. Joseph Ecklu (DCS)
10
3rd Generation
• Procedural languages : Main Issues
- Increasing the expressive power was given much
attention
- Reducing machine dependency ( 1970s)
- Increasing program correctness
- Reducing the complexity ( 1980 ) of both the
programming task and of the program management
task
- Exploiting Parallel and Distributed hardware
Mr. Joseph Ecklu (DCS)
11
3rd Generation
• Procedural languages
Increasing the expressive power was given much
attention
- New ideas like structured data ( COBOL )
recursion ( LISP )
user interactions ( BASIC )
Mr. Joseph Ecklu (DCS)
12
3rd Generation
• Procedural languages
Reducing machine dependency ( 1970s)
- Key word ‘portability’ achieved through
• a decreasing variety in hardware, operating systems
and character code
• improved compiler technology
• better programming style resulting from structured
programming
Mr. Joseph Ecklu (DCS)
13
3rd Generation
• Procedural languages
Increasing program correctness
- ‘Structured programming’
= a set of guidelines
for improved program structure
Examples:
Algol
Pascal,
Mr. Joseph Ecklu (DCS)
FORTRAN, COBOL
14
3rd Generation
• Procedural languages
Reducing the complexity ( 1980 ) of both the
programming task and of the program management
task. Example
- Object-Oriented language
Mr. Joseph Ecklu (DCS)
15
3rd Generation
• Procedural languages
Exploiting Parallel and Distributed hardware
- Systematic inclusion of parallel and distributed
hardware technologies in language as well
- Languages that allow problems to be solved
efficiently by splitting them into sub-problems that
can be worked on in parallel, by different machines
Mr. Joseph Ecklu (DCS)
16
3rd Generation
• Procedural languages
- Speed of sequential computers reach a limit and
parallelism must be used to obtain performance
beyond this limit
- RISC ( Reduced Instruction Set Computers ) hardware
has these properties
Mr. Joseph Ecklu (DCS)
17
3rd Generation
• Examples of languages
C
C++
JAVA
PASCAL
BASIC
(Visuals )
Mr. Joseph Ecklu (DCS)
18
4th Generation
• Application languages ( 4GLs )
- Exhibit strong data structure support
- Data are self-describing
- Data retain their existence between program calls (
they are persistent)
- Incorporate knowledge of the problem domain (eg.
Databases) and of the user
Mr. Joseph Ecklu (DCS)
19
4th Generation
• Examples of ( 4GLs )
databases
Structured Query Languages (SQL)
Mr. Joseph Ecklu (DCS)
20
5th Generation
• Artificial Intelligence techniques, inference languages
Are intended to allow non-specialist users to use
artificial intelligence techniques
Many are based on logical inference
Mr. Joseph Ecklu (DCS)
21
5th Generation
• Example
Prolog
LISP
CLISP
Mr. Joseph Ecklu (DCS)
22
6th Generation
• Neural networks
Are based on neural networks
Exhibit learning behaviour
Mr. Joseph Ecklu (DCS)
23
Topic Two
CLASSIFICATION OF LANGUAGES
BASED ON LEVEL /DEGREE OF
ABSTRACTION FROM MACHINE
Mr. Joseph Ecklu (DCS)
Slide 24
LEVEL OF ABSTRACTION FROM MACHINE
• Another classification of Languages is based on the
degree of abstraction from the machine
• LEVELS OF ABSTRACTION
- LOW LEVEL
- HIGH LEVEL
- VERY HIGH LEVEL
Mr. Joseph Ecklu (DCS)
25
LEVEL OF ABSTRACTION FROM
MACHINE
LEVEL
Instructions Memory
Handling
Examples
Low Level
languages ( LLLs)
Simple machine-like Direct memory
instructions
access and
allocation
Assembly
Languages
Autocode
High-Level
languages ( HLLs)
Expressions and
explicit flow of
control
Memory access and
allocation through
operators ( example
, new )
FORTRAN
PASCAL
JAVA
C++
Very High-Level
Languages (VHLLs)
Fully abstract
machine
Fully hidden
Prolog
memory access and
automatic
allocation
Mr. Joseph Ecklu (DCS)
26
Machine Language
Definition
• A machine language is a programming
language in which the instructions are in the
form that allows the computer to perform
them immediately, without any further
translation being required.
• Instructions in machine language are in the
form of a binary code, also called machine
code, and are called machine instructions.
Mr. Joseph Ecklu (DCS)
Ref. C.S. French Chapter 27.2
Slide 27
Machine Language
Instruction Set
• Instruction Set is the set of machine instructions that a
computer can perform.
7.
6.
5.
4.
3.
2.
1.
SOFTWARE
Application Layer
High Order Software
Operating System Layer
HARDWARE
Machine Layer
Microprogrammed Layer
Digital Logic Layer
Physical Device Layer
• This principle applies both at the microprogrammed layer and
the machine layer. This discussion is about the machine level.
Mr. Joseph Ecklu (DCS)
Ref. C.S. French Chapter 27.5
Slide 28
Machine Language
Types of Instruction set
• Arithmetic and Logic operations (instructions)
• Transfer Control or branch instruction
• Load (Fetch) and store Instructions
• Input/Output instruction
• Memory Reference Instructions
• Processor Instructions
Mr. Joseph Ecklu (DCS)
Ref. C.S. French Chapter 27.9
Slide 29
Low-Level Language
Definition
LOW-LEVEL LANGUAGES are languages in which each instruction
corresponds to or resembles a machine instruction.
LOCATIONS OF
INSTRUCTIONS
(OCTAL)
INDEX REGISTER
MACHINE INSTRUCTIONS (OR
DATA)
( OCTAL CODED )
MACHINE INSTRUCTIONS (OR DATA)
(BINARY)
FUNCTION
CODE
OPERAND OR OPERAND ADDRESS
MNEMONIC
EQUIVALENT
(Numeric Octal )
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
4
1
0
0
1
0
0
0
0
0
0
0
0
0
0
1
1
0
0
2
0
0
0
6
LDN
2
0
0
1
1
1
1
0
0
0
0
0
0
0
1
0
1
0
3
4
0
0
5
ADD
3
0
0
0
1
0
1
0
0
0
0
0
0
0
0
1
1
0
1
0
0
0
3
STA
4
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
1
7
0
0
0
0
STOP
5
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
0
0
0
0
0
6
6
6
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
0
0
0
0
1
2
12
7
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
Mr. Joseph Ecklu (DCS)
Ref. C.S. French Chapter 28
Slide 30
4
6
@5
3,X
Low-Level Language
Mnemonics
• Mnemonics are used to describe machinelevel instructions.
• It seems logical to write the program in
this SYMBOLIC form and to get the
machine to do the translation to machine
language.
Mr. Joseph Ecklu (DCS)
Ref. C.S. French Chapter 27
Slide 31
Low-Level Language
Features of Mnemonic
• Mnemonic codes are used in place of machine code
e.g. using LDA 5 in place of 0000000000000101
• Symbolic addresses are frequently used instead of
actual machine address e.g. LDA N where N stands
for the address, which can be assigned a numerical
value at a more convenient time
Mr. Joseph Ecklu (DCS)
Ref. C.S. French Chapter 27
Slide 32
Low-Level Language
Features of Mnemonic
• The (symbolic) low-level language must be translated
into machine language before use, because although
easier for the programmer to work with, it is not
usable by the machine in symbolic/mnemonic form.
Mr. Joseph Ecklu (DCS)
Ref. C.S. French Chapter 27
Slide 33
Low-Level Language
Example of LLL : Assembly Language
• Each computer manufacturer normally devices a lowlevel language that corresponds closely to the
particular machine language used by that
manufacturer.
• This language is called an ASSEMBLY LANGUAGE or
ASSEMBLER PROGRAM, which translates the ASSEMBLY
LANGUAGE into MACHINE CODE.
• A program written in ASSEMBLY LANGUAGE is called
the SOURCE PROGRAM. . The translated program in
MACHINE CODE is called the OBJECT PROGRAM.
Mr. Joseph Ecklu (DCS)
Ref. C.S. French Chapter 28.12
Slide 34
High Level Languages
Aim of HLL
The development of high-level languages was intended to
overcome the main limitations of LLL
which are :1. Program writing is a relatively time-consuming
business for the programmer because the
assembly process produces machine instructions
on a ONE-for-ONE basis
2. LLLs are machine orientated, each conforming to
the instruction set of the machine on which they
are used and therefore restricted to use on that
machine.
Mr. Joseph Ecklu (DCS)
Ref. C.S. French Chapter 31.31
Slide 35
High Level Languages
Characteristics of HLL
• Are intended to be machine independent and are
problem-orientated languages ( POLs), i.e. they reflect
the type of problem solved rather than the features of
the machine.
• Source programs are written in statements akin to
English (compare mnemonics )
• The machine independence of HLL means that in
principle it is possible to make the same HLL language
run on different machines and then write programs in
that language that are portable.
Mr. Joseph Ecklu (DCS)
Ref. C.S. French Chapter 31.39
Slide 36
High Level Languages
Program Portability
• A user of a program can change to a newer or bigger
machine without the need to rewrite the programs.
• Users of different computers may be able to share or
exchange programs and thereby reduce costs.
Mr. Joseph Ecklu (DCS)
Slide 37
High Level Languages
HLL Standardization
• Done at the international level by
International Standards Organization (ISO)
– Example is American National Standards Institution ( ANSI )
-
Generally Not Unix ( GNU )
Mr. Joseph Ecklu (DCS)
Slide 38
General Features of High Level Languages
• They have an extensive vocabulary of words, symbols and
sentences.
• Programs are written in the language and whole statements are
translated into many of machine instructions. This translation is
often done by a special program called a compiler.
• Libraries of macros and subroutines can be incorporated.
• As they are problem orientated the programmer is able to work,
at least to some extent, independently of the machine.
• A set of rules must be obeyed when writing the source program
(akin to rules of grammar in writing English)
• Instructions in high-level languages are usually called statements.
Mr. Joseph Ecklu (DCS)
Slide 39
Types of High Level Languages
• Commercial languages (COBOL, PASCAL, BASIC, Visual BASIC, C#)
• Scientific languages (eg. FORTRAN, ALGOL)
• Special-purpose languages - These are languages intended to be
‘tailor made’ for a particular type of problem (eg. SQL, QBE,
PROLOG, LISP, ADA)
• Command languages for OS (Languages used to control the
operations of the computer)
• Multipurpose languages - Languages intended to cope with a
number of different types of application areas e.g. business and
scientific. (eg. BASIC, C++, JAVA, Modula)
Mr. Joseph Ecklu (DCS)
Slide 40
Language Features
• Control Structures - While, do while, For loops, If..
then… else, CASE, SWITCH statements, C++ is very rich
in control structures
• Data Structures and files - Integer, float, double, char,
bool
• Computations - Facilities provided for mathematical
expressions and functions
• Procedures and subprograms - Facilities for handling
procedures and subprograms
Mr. Joseph Ecklu (DCS)
Ref. C.S. French Chapter 31.59
Slide 41
Other forms of High Level language
• Imperative/Procedural Languages-They provide facilities
for the programmer to express procedures or algorithms.
i.e., what to do and in what order.
• Assertional Languages -The programmer expresses
(asserts) what is required in a calculation rather than how
it is done.
There are two basic approaches to assertional programming:
• Logic programming , popular language = Prolog
• Functional programming, popular language = LISP
Mr. Joseph Ecklu (DCS)
Ref. C.S. French Chapter 31.61,62,63,65
Slide 42
Topic Two
PROGRAMMING PARADIGMS
In computer science a paradigm is a coherent set of methods that have
been found to be more or less, effective in handling a given type of
problem, the problem domain
Mr. Joseph Eklu (DCS)
Slide 43
Characteristics/components of A Paradigm
•
– Principle
• a single principle, simple to formulate ; the fact which is the
major source of the principles effectiveness
– Methods
• To apply the principle in practice, a number of methods and
/or techniques are required. Methods flow from the
principle
– Concepts (that support the methods)
• Each of the methods must be supported by a number of
concepts in order to function properly. They have their roots
in the principle
Mr. Joseph Ecklu (DCS)
44
PROGRAMMING PARADIGMS
• Paradigm may be viewed as a
Programming Style
• Paradigm may be viewed as a
Design Method for building systems
Mr. Joseph Ecklu (DCS)
45
A number of paradigms have been developed for the
programming problem. The most prominent ones are:
- the Imperative paradigm
- the object-oriented paradigm
- the functional paradigm and
- the logic paradigm
Mr. Joseph Ecklu (DCS)
46
The four major paradigms aim at
solving general programming problems
In some situations however, the programming problem has
additional aspects that have to be taken into account.
For example:
parallel and
distributed
programming;
Mr. Joseph Ecklu (DCS)
47
• Here the additional aspect is the requirement to
utilize optimally the available
multiple processors,
data storage and
their connections
Mr. Joseph Ecklu (DCS)
48
Principle
Methods
Concepts
Mr. Joseph Ecklu (DCS)
49
IMPERATIVE LANGUAGES : PRINCIPLE
PRINCIPLE
the basis of the imperative paradigm is
- fully specified
- fully controlled manipulation of a
- named data
in step-wise fashion to solve a general problem
Mr. Joseph Ecklu (DCS)
50
IMPERATIVE LANGUAGES : PRINCIPLE
The imperative principle
- fits/ suits the human mind
which is used to following instructions to
perform a given task e.g. recipe for preparing
a dish
- fits/ suits the hardware
which manipulates data in a step-wise
fashion
Mr. Joseph Ecklu (DCS)
51
• Steps in imperative programming
All that the programmer will have to do is to specify
- the named data
- the manipulations and to
- control the stepping
Mr. Joseph Ecklu (DCS)
52
IMPERATIVE LANGUAGES : PRINCIPLE
• Specify the named data
This is done through data declarations
• Data manipulation
This done through state-changing commands
• Controlling the stepping
This is done through flow control
Mr. Joseph Ecklu (DCS)
53
IMPERATIVE LANGUAGES : METHODS
Methods
DATA :Specify the named data through
data declarations
constant declarations
renaming and aliasing
overloading
types and type constructors
enumeration types
arrays
records and pointers
casting
Mr. Joseph Ecklu (DCS)
54
IMPERATIVE LANGUAGES : METHODS
Methods
State : Data manipulation is done through
state-changing commands
-INTERNAL STATE of the machine
as represented by values of its variables
-EXTERNAL STATE
as stored in its input/output devices
Mr. Joseph Ecklu (DCS)
55
IMPERATIVE LANGUAGES : METHODS
Methods
Internal State : Data manipulation done through
state-changing commands
assignments
statements
operators
expressions
infix notation
operator overloading and mixed mode
prefix and postfix notation
arithmetic
Mr. Joseph Ecklu (DCS)
56
IMPERATIVE LANGUAGES : METHODS
Methods
External State : Data manipulation
done through
state-changing commands
output statements
input statements
Mr. Joseph Ecklu (DCS)
57
IMPERATIVE LANGUAGES : METHODS
Method
Controlling the stepping
This is done through flow control
Sequencing
Selection
Routine invocation
Repetition
Mr. Joseph Ecklu (DCS)
58
IMPERATIVE LANGUAGES : HANDLING ERRORS
• Handling Errors :Run-Time error handling
Flow of control is often not smooth and may pose some
difficulties during run-time
The flow control mechanisms, often, cannot handle
them
Mr. Joseph Ecklu (DCS)
59
IMPERATIVE LANGUAGES : HANDLING ERRORS
• Three Main Causes of Run-Time error
– Domain / data errors
– Resource exhaustion
– Loss of facilities
Mr. Joseph Ecklu (DCS)
60
IMPERATIVE LANGUAGES :ADVANTAGES
• ADVANTAGES
Allow programmers to express algorithms which are
accurate descriptions of how to solve given problems
Can be implemented efficiently, just because the
mapping to the hardware is so straight forward
Mr. Joseph Ecklu (DCS)
61
IMPERATIVE LANGUAGES :DISADVANTAGES
• SOME DISADVANTAGES
– Tends to restrict the mental model of the programmer to
fit the structure of the machine
– Weak at building large systems
– Hard to integrate modules efficiently
– Difficult to manage complex system
– Difficult to understand complex system
– Difficult to make changes
Mr. Joseph Ecklu (DCS)
62
IMPERATIVE LANGUAGES : examples
•
•
•
•
ASSEMBLY
C
C++
VB
Mr. Joseph Ecklu (DCS)
63
Principle
Methods
Concepts
Mr. Joseph Ecklu (DCS)
64
OBJECT-ORIENTED LANGUAGES : PRINCIPLE
PRINCIPLE
the basis of the object-oriented paradigm is
the state of a program is encapsulated
objects
( these objects can be accessed only through
operations defined on them)
Mr. Joseph Ecklu (DCS)
65
in
An object contains data and provides
accessing these data
operations for
The data in an object are not visible directly, but can
only be accessed through the operations
The operations are the interface to the object for users
of the object
Mr. Joseph Ecklu (DCS)
66
OBJECT-ORIENTED LANGUAGES : PRINCIPLE
• AN OBJECT
object
DATA
OPERATIONS
•
USERS OF THE OBJECT
INTERFACE
•
Mr. Joseph Ecklu (DCS)
67
OBJECT-ORIENTED LANGUAGES : PRINCIPLE
• Data encapsulation
This principle is very essential to the object-oriented
paradigm
It establishes a firewall between the user of an object
and the code implementing it = information hiding
Mr. Joseph Ecklu (DCS)
68
OBJECT-ORIENTED LANGUAGES : METHODS
Methods + Concepts
classes
inheritance
class hierarchies
types
polymorphism
dynamic binding
reference semantics
Mr. Joseph Ecklu (DCS)
69
• ADVANTAGES
Emphasis is more on data than on control
Mr. Joseph Ecklu (DCS)
70
OBJECT-ORIENTED LANGUAGES :
examples
•
•
•
•
•
•
C++
JAVA
C#
VB
Smalltalk
Ada
Mr. Joseph Ecklu (DCS)
71
FUNCTIONAL LANGUAGES PARADIGM
Principle
Methods
Concepts
Mr. Joseph Ecklu (DCS)
72
• DECLARATIVE LANGUAGE
A Declarative language allows the programmer to
specify what has to be computed, rather than how the
computation is to be done.
Functional language is a declarative language
Mr. Joseph Ecklu (DCS)
73
PRINCIPLE
the basis of the functional languages paradigm is
the evaluation of expressions built out of
function calls ( application )
Mr. Joseph Ecklu (DCS)
74
PRINCIPLE
Global state variables and assignment are eliminated,
so the value computed by a function application
depends only on the arguments
State information is passed explicitly, through function
arguments and results
Mr. Joseph Ecklu (DCS)
75
• a function is like a pure mathematical function: it
maps values taken from one domain onto values of
another domain (co) domain
• a function computes a certain value, based on its
input parameters and nothing else
• Functions cannot have side-effects on the state of
the program, unless this state is carried around in the
arguments of the functions
Mr. Joseph Ecklu (DCS)
76
• Referential Transparency
means that the result of a function application
does not depend on when the function is called but
only on how it is called ( with which arguments )
Mr. Joseph Ecklu (DCS)
77
Methods + Concepts
functions
lists
types and polymorphism
higher-order functions
currying
lazy evaluation
equations and pattern matching
Mr. Joseph Ecklu (DCS)
78
• ADVANTAGES
Problem oriented
Problem is described through a collection of functions
Programmer can focus on the problem instead of on
instructing the computer
Deallocation of memory that is no longer used is done
automatically, using garbage collection
Recursive functions are possible
Mr. Joseph Ecklu (DCS)
79
• DISADVANTAGES
A bit mathematical
Mr. Joseph Ecklu (DCS)
80
• Mirinda
• Lisp
• Common Lisp
Mr. Joseph Ecklu (DCS)
81
Principle
Methods
Concepts
Mr. Joseph Ecklu (DCS)
82
• DECLARATIVE LANGUAGE
A Declarative language allows the programmer to
specify what has to be computed, rather than how the
computation is to be done.
Logic language is a declarative language
Mr. Joseph Ecklu (DCS)
83
• The idea of letting the programmer specify what the
problem is rather than how the computer is
supposed to solve it is taken one step further by logic
languages
• Logic program consists of facts and properties about
a problem, but it is up to the system to find the
solution to the problem
Mr. Joseph Ecklu (DCS)
84
PRINCIPLE
the basis of the logic languages paradigm is
due to a formalism called Horn logic that
specify problems and can also be
executed
automatically
Mr. Joseph Ecklu (DCS)
85
can
PRINCIPLE
the user can ask questions to the system by giving it
goals to prove
The system automatically tries to prove the goals using
the Horn clauses.
If the system is unable to prove the goal from the Horn
clauses it has available, it assumes that the goal is not
true
Mr. Joseph Ecklu (DCS)
86
PRINCIPLE
Horn clauses may use logical variables, denoting
unspecified objects
Horn clauses express relations rather than functions
Structures and lists are the most important data structures
For efficiency, the programmer may control the order in
which alternative clauses for a goal are tried as well as the
order in which different sub-goals are tried
Mr. Joseph Ecklu (DCS)
87
Methods + Concepts
Horn clauses
logical variables
relations
data structures
search order
Mr. Joseph Ecklu (DCS)
88
• ADVANTAGES
Problem-oriented
Mr. Joseph Ecklu (DCS)
89
• DISADVANTAGES
Some programmer effort is required
Mathematical
Mr. Joseph Ecklu (DCS)
90
• Prolog
Application
Used extensively in building
- Databases
- Knowledge-based systems
- Reasoning systems
- Heuristic search problems
- Compiler construction
Mr. Joseph Ecklu (DCS)
91
PARALLEL AND DISTRIBUTED
LANGUAGES
PRINCIPLE
Parallel and distributed languages differ from the
imperative and declarative languages
They contain explicit constructs for running pieces of a
program in parallel
Mr. Joseph Ecklu (DCS)
92
PARALLEL AND DISTRIBUTED
LANGUAGES
• Parallel System
any system with multiple
Central Processing Units ( CPU )
Mr. Joseph Ecklu (DCS)
93
PARALLEL AND DISTRIBUTED
LANGUAGES
One example of Parallel Systems
Multiple Instruction Multiple Data ( MIMD) class
Each processor in MIMD system executes its own
instruction stream ( program ) on its own data
Each processor in MIMD system is to a large degree
independent
Mr. Joseph Ecklu (DCS)
94
Therefore, processors in a MIMD system must be able
to
communicate
Mr. Joseph Ecklu (DCS)
95
PARALLEL AND DISTRIBUTED LANGUAGES
Communication can either be done through
shared memory
or
over a network
Giving rise to two MIMD machines
multiprocessors
And
multicomputers
Mr. Joseph Ecklu (DCS)
96
PARALLEL AND DISTRIBUTED
LANGUAGES
Communication over : network
MIMD machine multicomputers
memory
memory
memory
CPU
CPU
CPU
network
Mr. Joseph Ecklu (DCS)
97
PARALLEL AND DISTRIBUTED
LANGUAGES
MultiComputer
- The memory is distributed
- Each CPU can only access its own local memory
But
CPUs can communicate through a network that
connects them
This type of machine is called
Distributed System
Mr. Joseph Ecklu (DCS)
98
PARALLEL AND DISTRIBUTED
LANGUAGES
Communication through : shared memory
MIMD machines multiprocessors
CPU
CPU
CPU
bus
Shared
memory
Mr. Joseph Ecklu (DCS)
99
PARALLEL AND DISTRIBUTED
LANGUAGES
Multiprocessor
- All CPUs access a single global shared memory
And
The shared memory is used for communication
between the CPUs
Mr. Joseph Ecklu (DCS)
100
PARALLEL AND DISTRIBUTED
LANGUAGES
Parallel Programming denotes programming on both
Multiprocessor and
multicomputer systems
Mr. Joseph Ecklu (DCS)
101
PARALLEL AND DISTRIBUTED
LANGUAGES
Distributed Programming
Parallel Language constructs are needed for the
construction of programs that run on distributed
systems made out of workstations connected by a local
area network such as an Ethernet
Mr. Joseph Ecklu (DCS)
102
PARALLEL AND DISTRIBUTED
LANGUAGES
Distributed Programming
The user on one workstation may want to send
electronic mail to users on other workstations
The e-mail program is a distributed application that
runs on multiple machines
Examples: airline reservation systems
banking system
Mr. Joseph Ecklu (DCS)
103
PARALLEL AND DISTRIBUTED
LANGUAGES
Parallel language
can be used for Parallel Programming
Distributed language
can be used for Distributed Programming
Both support Parallelism
Mr. Joseph Ecklu (DCS)
104
Methods + Concepts
processes
co-routines
parfor and parbegin statements
Mr. Joseph Ecklu (DCS)
105
PROGRAMMING PARADIGMS
POPULAR PARADIGMS DISCUSSED
–IMPERATIVE
–OBJECT-ORIENTED
–FUNCTIONAL
–LOGIC
–PARALLELISM
Mr. Joseph Ecklu (DCS)
106
Trial Questions
1. Bellow are list of existing programming languages.
Group then under the following headings imperative , object-oriented , functional
and logic programming.
Haskell
ML
C
Java
Python
C++
PHP
ProLog
LISP
Scheme
C#
Ruby
Agda
Scala
F#
2. Define the term Object as used in Object-Oriented Paradigm
3. List 5 state changing commands as used in imperative languages
4. Give two advantages of imperative languages
5. List 3 examples of control flow commands in imperative programming languages
Mr. Joseph Ecklu (DCS)
107
Trial Questions
6. Explain the term referential transparency as used in functional
programming
7. What are the disadvantages of the functional programming paradigm
8. State three application areas in which logic programming is usually
employed
9. Define the following terms
a. Parallel Programming
b. Distributed Programming
10. State the two examples of MIMD machines
Mr. Joseph Ecklu (DCS)
108
PROGRAMMING PARADIGMS
•END OF SESSION
Mr. Joseph Ecklu (DCS)
109