Theory of Programming
Languages
LECTURE#1
Chapter # 1
Preliminaries
What is Programming?
Programming
Programming is a creative process that
instructs a computer on how to do a task.
What is Programming Language?
Programming Language
Coded Language used by programmers to write
instructions that a computer can understand.
What is Programming Paradigm?
A programming paradigm is the
classification, style or way of
programming. It is an approach to
solve problems by using programming
languages.
Programming Paradigm
Imperative - programming paradigm
One of the oldest programming paradigm.
It is based on Von Neumann architecture.
It performs step by step task by changing state.
The main focus is on how to achieve the goal.
The paradigm consist of several statements and after execution of all
the result is stored.
Imperative - programming paradigm
Examples of Imperative programming paradigm:
C : developed by Dennis Ritchie and Ken Thompson
Fortran : developed by John Backus for IBM
Basic : developed by John G Kemeny and Thomas E Kurtz
Imperative - programming paradigm
Write a program to take average of five numbers in C.
Imperative - programming paradigm
Imperative programming is divided into three broad categories:
Procedural,
OOP and
parallel processing
Procedural - Imperative
emphasizes on procedure
Examples are:
C
C++
Java
ColdFusion
Pascal
Procedural - Imperative
Write a program to find factorial of any number in C++.
Object oriented programming –
Imperative
a collection of classes and object
Real world objects, states and behaviors
Examples are:
Simula
Java
C++
Objective-C
Visual Basic .NET
Python
Ruby
Smalltalk
Parallel processing approach –
Imperative
numbers of processor
Objective: running a program in less time by dividing them
divide and conquer
Examples are NESL (one of the oldest one) and C/C++ also supports
because of some library function.
Declarative programming paradigm
expresses logic of computation
focus on what needs to be done rather how it should be done
(emphasize on what code is actually doing).
It is divided as:
Logic,
Functional,
Database.
Logic programming paradigms -
Declarative
Solve logical problems like puzzles
Example: Prolog
Functional programming paradigms -
Declarative
The central model for the abstraction is the function (meant for some
specific computation) and not the data structure.
Some of the languages like perl, javascript mostly uses this paradigm.
Database/Data driven programming
approach – Declarative
based on data
provides file creation, data entry, update, query and reporting functions
For example SQL.
Difference
Imperative Declarative
how to do what to do
Language Evaluation Criteria
Readability
Writability
Reliability
Cost
Language Design Trade-offs
Two criteria that conflicts are reliability and cost of execution.
For example:
Java language definition demands that all references to an array
elements be checked.
This step add a great deal to the cost of execution of Java Programs.
C does not require index range checking, so C programs executes faster
than semantically equivalent Java programs, although java programs
are more reliable.
The designers of java traded execution efficiency for reliability.
Algorithm
Algorithm is Computational procedure to solve a problem.
Algorithm vs Program
Program Algorithm
Programming Language Pseudocode/Structured English
Computer Model of Computation OR
Architecture of Computer (Influence
on language design)
Model of Computation
Specifies
What operations an algorithm is allowed.
Model of Computation
Model of Computation