L02 OverviewOfProgrammingParadigms
L02 OverviewOfProgrammingParadigms
Lecture Objectives:
Be able to explain the differences between programming languages and programming paradigms. Be able to differentiate between low-level and high-level programming languages and their associated advantages and disadvantages Be able to list four programming paradigms and describe their strengths and weaknesses.
Computer Programming
The functions of a computer system are controlled by computer programs A computer program is a clear, step-by-step, finite set of instructions
A computer program must be clear so that only one meaning can be derived from it,
A computer program is written in a computer language called a programming language
Programming Languages
There are three categories of programming languages:
1. 2. 3. Machine languages. Assembly languages. High-level languages.
Machine languages and assembly languages are also called low-level languages
Advantages
Fast and efficient
Machine oriented No translation required
Disadvantages
Not portable Not programmer friendly
Assembly Language
Assembly language programs use mnemonics to represent machine instructions Each statement in assembly language corresponds to one statement in machine language. Assembly language programs have the same advantages and disadvantages as machine language programs. Compare the following machine language and assembly language programs:
1010 0001 0000 0000 0000 0000 MOV AX , var1 0000 0011 0000 0110 0000 0000 0000 0010 ADD AX , var2 1010 0011 0000 0000 0000 0000 MOV var1 , AX
5
A HLL language program consists of English-like statements that are governed by a strict syntax. Advantages
Portable or machine independent Programmer-friendly
Disadvantages
Not as efficient as low-level languages Need to be translated
Programming Paradigms
Why are there hundreds of programming languages in use today?
Some programming languages are specifically designed for use in certain applications. Different programming languages follow different approaches to solving programming problems
A programming paradigm is an approach to solving programming problems. A programming paradigm may consist of many programming languages.
Advantages
low memory utilization relatively efficient the most common form of programming in use today.
Disadvantages
difficulty of reasoning about programs
difficulty of parallelization.
Tend to be relatively low level.
Advantages
Conceptual simplicity Models computation better Increased productivity.
Disadvantages
Can have a steep learning curve, initially Doing I/O can be cumbersome
10
Disadvantages
Slow execution Limited view of the world That means the system does not know about facts that are not its predicates and rules of inference. Difficulties in understanding and debugging large programs
11
12
Review Questions
1. List two advantages and two disadvantages of low-level languages. 2. Explain the similarities and differences between an assembly language and a machine language. 3. Mention the programming paradigm to which each of the following languages belongs: Visual Basic, Java, C#, Haskell, Lisp, Prolog, Pascal. 4. Which programming paradigms give better support for reasoning about programs? 5. Which programming paradigms give better support for doing I/O?
13