SlideShare a Scribd company logo
PROGRAMMING PARADIGMS
Cooperative Information Systems
Edward Blurock
Programming Paradigms Introduction CIS: Edward Blruock
Why are there so many programming
languages?
Lecture: Programming
Paradigm
programming CIS: Edward Blruock
Human Computer Interface
The
Program
Why are there so many programming
languages?
Lecture: Programming
Paradigm
programming CIS: Edward Blruock
Historically, the first programs were close to the computer level
The
Program
The
Program
The
Program
Human Computer Interface
But as programming languages are evolving
Organizational structure are becoming more human
Lecture: Programming
Paradigm
CIS: Edward Blruock
Why are there so many programming
languages?
The
Program
Mathematical concepts
The computer
Organizational Concepts:
Program flow, data organization What influences
program language
design?
FORMAL BASIS OF
PROGRAMMING LANGUAGES
Mathematical Basis
Lecture: Programming
Paradigm
CIS: Edward Blruock
Algorithm
slide 6
• Abu Ja’far Muhammad ibn Musa
al-Khorezmi (“from Khorezm”)
– Lived in Baghdad around 780 – 850
AD
– Chief mathematician in Khalif Al
Mamun’s “House of Wisdom”
– Author of “A Compact Introduction To
Calculation Using Rules Of Completion
And Reduction”
Removing negative units from the equation by
adding the same quantity on the other side (“al-
gabr” in Arabic)
slide 7
“Calculus of Thought”
• Gottfried Wilhelm Leibniz
– 1646 - 1716
– Inventor of
calculus and binary system
– “Calculus ratiocinator”
human reasoning can be reduced to a
formal symbolic language,
in which all arguments would be settled by
mechanical manipulation of logical
concepts
– Invented a mechanical calculator
slide 8
Formalisms for Computation (1)
• Predicate logic
– Gottlöb Frege (1848-1925)
– Formal basis for proof theory
and automated theorem proving
– Logic programming
• Computation as logical deduction
• Turing machines
– Alan Turing (1912-1954)
– Imperative programming
• Sequences of commands, explicit
state transitions, update via
assignment
slide 9
Formalisms for Computation (2)
• Lambda calculus
– Alonzo Church (1903-1995)
– Formal basis for all functional
languages, semantics, type
theory
– Functional programming
• Pure expression evaluation, no
assignment operator
• Recursive functions & automata
– Stephen Kleene (1909-1994)
– Regular expressions, finite-state
machines, PDAs
slide 10
Programming Language
• Formal notation for specifying computations
– Syntax (usually specified by a context-free
grammar)
– Semantics for each syntactic construct
– Practical implementation on a real or virtual
machine
• Translation vs. compilation vs. interpretation
– C++ was originally translated into C by Stroustrup’s Cfront
– Java originally used a bytecode interpreter, now native code
compilers are commonly used for greater efficiency
– Lisp, Scheme and most other functional languages are
interpreted by a virtual machine, but code is often
precompiled to an internal executable for efficiency
• Efficiency vs. portability
slide 11
Computability
• Function f is computable if some program
P computes it
– For any input x, the computation P(x) halts
with output f(x)
– Partial recursive functions: partial functions
(int to int) that are computable
slide 12
Halting Problem
Ettore Bugatti: "I make my
cars to go, not to stop"
slide 13
Program Correctness
• Assert formal correctness statements about
critical parts of a program and reason
effectively
– A program is intended to carry out a specific
computation, but a programmer can fail to
adequately address all data value ranges, input
conditions, system resource constraints, memory
limitations, etc.
• Language features and their interaction should
be clearly specified and understandable
– If you do not or can not clearly understand the
semantics of the language, your ability to
accurately predict the behavior of your program is
limited
slide 14
Billion-Dollar Mistake
Failed launch of Ariane 5 rocket (1996)
– $500 million payload; $7 billion spent on development
Cause: software error in inertial reference system
– Re-used Ariane 4 code, but flight path was different
– 64-bit floating point number related to horizontal
velocity converted to 16-bit signed integer; the number
was larger than 32,767; inertial guidance crashed
HISTORY OF
PROGRAMMING LANGUAGES
Evolutionary Development
9/15/2015 15
First modern computer – first compiler
 David Wheeler (1927-2004)
 University of Cambridge
 Exceptional problem solver: hardware, software, algorithms, libraries
 First computer science Ph.D. (1951)
 First paper on how to write correct, reusable, and maintainable code (1951)
 (Thesis advisor for Bjarne Stroustrup )
16Stroustrup/Programming
slide 17
Assembly Languages
• Invented by machine designers
the early 1950s
• Mnemonics instead of
binary opcodes
push ebp
mov ebp, esp
sub esp, 4
push edi
• Reusable macros and subroutines
slide 18
FORTRAN
• Procedural, imperative language
– Still used in scientific computation
• Developed at IBM in the 1950s by
John Backus (1924-2007)
– Backus’s 1977 Turing award lecture (see course
website) made the case for functional programming
– On FORTRAN: “We did not know what we wanted and
how to do it. It just sort of grew. The first struggle was
over what the language would look like. Then how to
parse expressions – it was a big problem…”
• BNF: Backus-Naur form for defining context-free grammars
slide 19
LISP
• Invented by John McCarthy (b. 1927,
Turing award: 1971)
– See original paper on course website
• Formal notation for lambda-calculus
• Pioneered many PL concepts
– Automated memory management
(garbage collection)
– Dynamic typing
– No distinction between code and data
• Still in use: ACL2, Scheme, …
slide 20
Algol 60
• Designed in 1958-1960
• Great influence on modern languages
– Formally specified syntax (BNF)
• Peter Naur: 2005 Turing award
– Lexical scoping: begin … end or {…}
– Modular procedures, recursive procedures, variable
type declarations, stack storage allocation
• “Birth of computer science” -- Dijkstra
• “A language so far ahead of its time that it
was not only an improvement on its
predecessors, but also on nearly all its
successors” -- Hoare
slide 21
Algol 60 Sample
real procedure average(A,n);
real array A; integer n;
begin
real sum; sum := 0;
for i = 1 step 1 until n do
sum := sum + A[i];
average := sum/n
end;
no ; here
no array bounds
set procedure return value by assignment
Simula 67
• Kristen Nygaard (1926-2002) and Ole-Johan Dahl (1931-2002)
– Norwegian Computing Center
– Oslo University
– The start of object-oriented programming and object-oriented design
22Stroustrup/Programming
slide 23
Pascal
• Designed by Niklaus Wirth
– 1984 Turing Award
• Revised type system of Algol
– Good data structure concepts
• Records, variants, subranges
– More restrictive than Algol 60/68
• Procedure parameters cannot have procedure
parameters
• Popular teaching language
• Simple one-pass compiler
slide 24
C
• Bell Labs 1972 (Dennis Ritchie)
• Development closely related to UNIX
– 1983 Turing Award to Thompson and
Ritchie
• Added weak typing to B
– int, char, their pointer types
– Typed arrays = typed pointers
• int a[10]; … x = a[i]; means
x = *(&a[0]+i*sizeof(int))
• Compiles to native code
slide 25
C++
• Bell Labs 1979 (Bjarne Stroustrup)
– “C with Classes” (C++ since 1983)
• Influenced by Simula
• Originally translated into C using
Cfront, then native compilers
– GNU g++
• Several PL concepts
– Multiple inheritance
– Templates / generics
– Exception handling
slide 26
Java
• Sun 1991-1995 (James Gosling)
– Originally called Oak,
intended for set top boxes
• Mixture of C and Modula-3
– Unlike C++
• No templates (generics), no multiple inheritance, no
operator overloading
– Like Modula-3 (developed at DEC SRC)
• Explicit interfaces, single inheritance, exception
handling, built-in threading model, references &
automatic garbage collection (no explicit pointers!)
• “Generics” added later
slide 27
Why So Many Languages?
“There will always be things we wish to
say in our programs that in all languages
can only be said poorly.”
- Alan Perlis
slide 28
What’s Driving Their Evolution?
• Constant search for better ways to build software
tools for solving computational problems
– Many PLs are general purpose tools
– Others are targeted at specific kinds of problems
• For example, massively parallel computations or graphics
• Useful ideas evolve into language designs
– Algol  Simula  Smalltalk  C with Classes  C++
• Often design is driven by expediency
– Scripting languages: Perl, Tcl, Python, PHP, etc.
• “PHP is a minor evil perpetrated by incompetent amateurs,
whereas Perl is a great and insidious evil, perpetrated by skilled
but perverted professionals.” - Jon Ribbens
slide 29
What Do They Have in Common?
• Lexical structure and analysis
– Tokens: keywords, operators, symbols, variables
– Regular expressions and finite automata
• Syntactic structure and analysis
– Parsing, context-free grammars
• Pragmatic issues
– Scoping, block structure, local variables
– Procedures, parameter passing, iteration, recursion
– Type checking, data structures
• Semantics
– What do programs mean and are they correct
slide 30
Core Features vs. Syntactic Sugar
• What is the core high-level language syntax
required to emulate a universal Turing machine?
– What is the core syntax of C?
• Are ++, --, +=, -=, ?:, for/do/while part of the core?
• Convenience features?
– Structures/records, arrays, loops, case/switch?
– Preprocessor macros (textual substitution)
– Run-time libraries
• String handling, I/O, system calls, threads, networking, etc.
– “Syntactic sugar causes cancer of the semicolons”
- Alan Perlis
slide 31
Where Do Paradigms Come From?
• Paradigms emerge as the result of social
processes in which people develop ideas
and create principles and practices that embody
those ideas
– Thomas Kuhn. “The Structure of Scientific
Revolutions.”
• Programming paradigms are the result of
people’s ideas about how programs should be
constructed
– … and formal linguistic mechanisms for expressing
them
– … and software engineering principles and
practices for using the resulting programming
language to solve problems
Paradigms
• Programming paradigm is a fundamental
style of computer programming
• Paradigms differ in concepts and
abstractions used to represent the
elements of program
Paradigms
v1.0 © 2007 by Peter Van Roy
Turing equivalent
Data structures only
(channel)
+ port
(state)
+ cell
Java, OCaml
+ cell (state)
Event−loop
programming
Sequential
object−oriented
programming
Stateful
functional
programming
Functional
programming
First−order
programming
+ procedure
functional
+ nondeterministic
FGHC, FCP,
+ name
Encapsulated
functional
programming
+ closure
Pascal, C,
Imperative
programming
Prolog
Scheme, ML
constraint
Prolog, SQL
+ search
+ solver
Constraint (logic)
programming
Concurrent
(equality)
+ thread
Lazy
constraint
programming
programming
Relational & logic
Deterministic
logic programming
+ unification
LIFE, AKL
programming (FRP)
CLP, ILOG Solver
Weak state StatefulNo state
constraints
Logic and
Functional Message passing
+ closure
programming
Nonmonotonic
programming
dataflow
Concurrent logic
programming
Oz, Alice, AKL
dataflow
programming
(channel)
+ port
Multi−agent
Shared state
Functional reactive
FrTime
+ by−need synchronization + synchronization
on partial termination
choice
CLU, E, Oz
(unforgeable constant)
+ thread
declarative
Lazy
programming
dataflow
programming
+ single assignment
Lazy
concurrent
Lazy
functional
synchron.
+ by−need
programming
+ thread
+ single assign.
programming
concurrent
Haskell
Monotonic
dataflow
programming
Declarative
Unix pipes
+ by−need
synchronization Oz, Alice, AKL
+ local cell
programming
Active object
Object−capability
programming
publish/subscribe,
E, Oz, Alice,
tuple space (Linda)
Erlang, AKL
+ thread
Multi−agent
programming
Message−passing
concurrent
programming
Oz, Alice
Java, Oz,
Shared−state
concurrent
programming
object−oriented
Concurrent
programming
+ thread
Alice
Oz, Alice
Dataflow and
message passing
The principal programming paradigms
"More is not better (or worse) than less, just different."
Each language is placed next to a programming paradigm it supports well.
Inspired by "Concepts, Techniques, and Models of Computer Programming."
+ log
Software
transactional
memory (STM)
SQL
record
declarative
programming
XML
Descriptive
Lecture: Programming
Paradigm
Overview CIS: Edward Blruock
Major Paradigms
• Imperative
• Functional
• Declarative
• Object Oriented
• Event-Driven
• Stochastic
There are many ways to
categorize programming
paradigms.
It should also be said that
they are not mutually
exclusive.
Lecture: Programming
Paradigm
Overview CIS: Edward Blruock
IMPERATIVE LANGUAGES
Programming Paradigms
9/15/2015 Imperative 35
Imperative Programming
• Derived from latin word imperare means
“to command”
• It is based on commands that update
variables in storage
• Is a programming paradigm that describes
computation in terms of statements that
change a program state.
Contd..
• It defines sequences of commands for the
computer to perform
• Imperative programming is characterized
by programming with a state and
commands
Contd..
• In imperative programming, a name may
be assigned to a value and later
reassigned to another value.
• A name is tied to two bindings, a binding
to a location and to a value.
• The location is called the l-value and the
value is called the r-value.
Contd..
• For example,
– X := X+2
• Assignment changes the value at a
location.
• A program execution generates a
sequence of states
Unstructured Commands
• The unstructured commands contains:
– assignment command,
– sequential composition of commands,
– a provision to identify a command with a
label,
– unconditional and conditional GOTO
commands
L-value and r-value
• l-value: address/location
– lifetime
– memory allocation
• r-value: contents/encoded value
– initialization
– constants
* binding
Iteration
• For statement
– Loop control variable
• The while loop
• while vs do-while
• do-while versus repeat-until
• Iteration using goto
Goto statement
Loops a GOTO (or similar) statement
The GOTO jumps to a specified location (label or address)
n!º i
i=1
n
Õ
an index involved
The index is incremented until the end is reached i=1
factorial = 1;
loop:
factorial = factorial * I
if( i=n) goto exit
goto loop
exit
Structured Programming
• The goal of structured programming is to
provide control structures that make it
easier to reason about imperative
programs.
Contd..
• an IF statement corresponds to an If
condition then command and a DO
statement corresponds to a While
condition Do command.
– IF guard --> command FI=if guard then
command
– DO guard --> command OD=while guard do
command
Iteration
Repetition of a block of code
n!º i
i=1
n
Õ
an index involved
The index is incremented until the end is reached
i=1
factorial = 1;
while( i <= n) {
factorial = factorial * i
i = i + 1
}
Once again involves a iteration counter
factorial = 1;
for i=1 to n {
factorial = factorial * I
}
Programming Paradigms: Functional
 A program in this paradigm consists of functions and uses functions in a similar
way as used in mathematics
Program execution involves functions calling each
other and returning results. There are no variables in
functional languages.
 Example functional languages include: ML, MirandaTM, Haskell
 Advantages
Small and clean syntax
Better support for reasoning about programs
They allow functions to be treated as any other data
values.
They support programming at a relatively higher level
than the imperative languages
 Disadvantages
Difficulty of doing input-output
Functional languages use more storage space than their imperative cousins
Possible Benefits
• The ability to re-use the same code at
different places in the program without
copying it.
• An easier way to keep track of program
flow than a collection of "GOTO" or
"JUMP" statements
Functional Programming
• It treats computation as the evaluation of
mathematical functions and avoids state
and mutable data.
• It emphasizes the application of functions,
in contrast to the imperative programming
style
Recursion
Numerische Mathematik 2, 312--318 (1960)
Content of Recursion
• Base case(s).
o Values of the input variables for which we perform no recursive calls
are called base cases (there should be at least one base case).
o Every possible chain of recursive calls must eventually reach a base
case.
• Recursive calls.
o Calls to the current method.
o Each recursive call should be defined so that it makes progress
towards a base case.
factorial(n) {
if(n=1) return 1
return factorial(n-1)*n
}
n!º
1 n =1
n*(n-1)! n >1
ì
í
ï
îï
ü
ý
ï
þï
How do I write a
recursive function?
• Determine the size factor
o The number: smaller number, smaller size
• Determine the base case(s)
o The case for n=1, the answer is 1
• Determine the general case(s)
o The recursive call: factorial(n)=factorial(n-1)*n
• Verify the algorithm
(use the "Three-Question-Method")
factorial(n) {
if(n=1) return 1
return factorial(n-1)*n
}
n!º
1 n =1
n*(n-1)! n >1
ì
í
ï
îï
ü
ý
ï
þï
Three-Question Verification Method
1. The Base-Case Question:
Is there a nonrecursive way out of the function, and does
the routine work correctly for this "base" case?
2. The Smaller-Caller Question:
Does each recursive call to the function involve a smaller
case of the original problem, leading inescapably to the
base case?
3. The General-Case Question:
Assuming that the recursive call(s) work correctly, does
the whole function work correctly?
Stacks
in recursion
factorial(n)
If (n=1)
return 1
else
return factorial(n-1)
n! = n*(n-1)*(n-2)*(n-3)*……* 1
5! = 5*4*3*2*1
Factorial(5)
Factorial(4)
Factorial(3)
Factorial(2)
Factorial(1) return 1
Return 2
Return 6
Return 24
Return 120 5!=120
Deep recursion can result in
running out of memory
DECLARATIVE PROGRAMMING
Programming Paradigms
9/15/2015 55
Declarative Programming
Not a recipe
Does not explicitly list command or steps
that need to be carried out to achieve the results.
Set of Declarations
separates the process of
stating a problem from the process of solving the problem.
The domain is described through a set of declarations
An external “engine” interprets these declarations to perform a task
Programmed Behavior
Lecture: Programming
Paradigm
Declarative CIS: Edward Blruock
Digger Wasps are predators that can sting and paralyze prey insects.
They construct a protected “nest
and then stock it with captured insects.
The wasps lay their eggs in the provisioned nest.
When the wasp larvae hatch, they feed on the paralyzed insects.
1. Dig nest
2. Place paralyzed insect at nest entrance
3. Go in and inspect nest
4. Come out
5. Take paralyzed insect in nest
Programmed Behavior
Lecture: Programming
Paradigm
Declarative CIS: Edward Blruock
1. Dig nest
2. Place paralyzed insect at nest entrance
3. Go in and inspect nest
4. Come out
5. Take paralyzed insect in nest
If during step 3, when the insect is inside the nest,
the researcher removes the insect
The insect will go back to step 2, retrieve the insect
and, again step 3, inspect the nest.
Programmed Behavior
Lecture: Programming
Paradigm
Declarative CIS: Edward Blruock
1. Dig nest
2. Place paralyzed insect at nest entrance
3. Go in and inspect nest
4. Come out
5. Take paralyzed insect in nest
Imperative View:
A recipe, step 1, before step 2, before step 3….
Fixed programming can lead to (unexpected) problems.
Declarative Paradigm
Lecture: Programming
Paradigm
Declarative CIS: Edward Blruock
Not a recipe for the computer
Imperative programming
Declarative Programming
Computer
Sets up a set of (reactive) states
Engine
“Recipe” Built (compiled)
Directly in Computer
States are managed
By an “engine”
Built (compiled)
Directly in Computer
Declarative programming
Expresses the logic of a computation
without describing its control flow.
n!º
1 n =1
n*(n-1)! n >1
ì
í
ï
îï
ü
ý
ï
þï
factorial(1,1) factorial(N,F) :-
N1 is N-1,
factorial(N1,F1),F is N*F1.
The problem is (mathematically) described
The engine takes care of the solving/using the description
Solving predicate logic is the engine
Declarative Programming
Lecture: Programming
Paradigm
Declarative Programming CIS: Edward Blruock
PROLOG:
Horn clause predicate:
P(X,Y,…) :=
Condition1(…),
Condition2(…),
....
If these conditions are true,
then the predicate is true
Backward chaining:
examine conditions to determine truth of predicate
(p ∧ q ∧ ... ∧ t) → u
Rules
• Consider the following sentence :
– 'All men are mortal'
• We can express this as :
– mortal(X) :- human(X).
• Let us define the fact that Socrate is a
human.
– mortal(X) :- human(X).
human(socrate).
Contd..
• Now if we ask to prolog :
– ?- mortal(socrate).
• What prolog will respond ?
• Why ?
Constraint Logic Programming
factorial(1,1) factorial(N,F) :-
N1 is N-1,
factorial(N1,F1),F is N*F1.
Factorial(5,F) Returns F=120
Factorial(N.120) Creates an instantiation error
PROLOG has no knowledge of Real or Integer numbers
Mathematical manipulations cannot be made
Constraint Logic Programming
factorial(1,1) factorial(N,F) :-
N1 is N-1,
factorial(N1,F1),F is N*F1.
Logic Programming
Constraint Logic Programming
CLP
Formulas passed to
CLP
Reduced or solved
formulas returned
Mathmatical knowledge
about the numbers used
Declarative Programming
9/15/2015 67
Subclass:
Reactive systems
Response to a set of conditions
Declaration:
1. The set of conditions
2. The response
Declarative Programming
Lecture: Programming
Paradigm
Declarative Programming CIS: Edward Blruock
Expert Systems (is the engine):
A set of rules.
The rule executes if the conditions hold.
Rules:
1. If X croaks and eats flies - Then X is a frog
2. If X chirps and sings - Then X is a canary
3. If X is a frog - Then X is green
4. If X is a caary - Then X is yellow
1. Fritz croaks and Fritz eats flies
Based on logic, the computer can derive:
2. Fritz croaks and eats flies
Based on rule 1, the computer can derive:
3. Fritz is a frog
Based on rule 3, the computer can derive:
4. Fritz is green.
Facts
1. Fritz croaks
2. Fritz eats flies
Declarative Programming
Lecture: Programming
Paradigm
Declarative Programming CIS: Edward Blruock
GUI Interface:
An action, activated by conditions, produces a response.
Don’t
Press
Action
The
System
Explodes!
Response
Declarative Programming
Lecture: Programming
Paradigm
Declarative Programming CIS: Edward Blruock
System of agents (on the internet):
An agent responds, if it sees the right conditions.
Agent
Agent
Agent
Agent
Agent
Agent
Agent
Declarative Programming
Lecture: Programming
Paradigm
Declarative Programming CIS: Edward Blruock
Environment Declaration Engine
PROLOG Horn Clause Predicate Logic: Backward chaining
Expert System A rule or fact Expert System: Forward chaining
GUI An action function GUI/Operating system
System of Agents Program within agent Internet message passing
Contd..
• It is a paradigm where we focus real life
objects while programming any solution.
• We actually write behaviours of our
programming objects, those behaviours
are called methods in objected oriented
programming.
Principal advantage
• They enable programmers to create
modules that do not need to be changed
when a new type of object is added.
• A programmer can simply create a new
object that inherits many of its features
from existing objects.
Fundamental Concepts
• Class
• Object
• Instance
• Method
• Message passing
• Inheritance
• Abstraction
• Encapsulation
• Polymorphism
• Decoupling
Main features
• Encapsulation:
– a logical boundary around methods and
properties
• Inheritance
• Re-usability
– method overloading and overriding
• Information Hiding
– is achieved through "Access Modifiers"
Probabilistic Algorithms
Non-deterministic
No exact control program flow
Leaves Some of Its Decisions To Chance
Outcome of the program in different runs is not necessarily the same
Monte Carlo Methods
Always Gives an answer
But not necessarily Correct
The probability of correctness go es up with time
Las Vegas Methods Never returns an incorrect answer
But sometimes it doesn’t give an answer
Probabilistic Algorithms
Probabilistic Algorithms in optimization:
Closer to human reasoning and problem solving
(for hard problems we don’t follow strict deterministic algorithms)
Finding
local and global
minimum
Probabilistic Algorithms
Classic gradient optimization find local minimum
The search path is always downhill toward minimum
Probabilistic algorithms allow search to go uphill sometimes
Randomness in the search for next step
Genetic Algorithms
Simulated Annealing to find global minimum
Probabilistic Algorithms
Calculate pi with a dart board
Area of square
d2
Area of Circle:
P
d
2
æ
è
ç
ö
ø
÷
2
prob =
circle
square
=
p
d
2
æ
è
ç
ö
ø
÷
2
d2
=
p
4
Probability dart will be in circle
d
number darts in circle
divided by
number of darts in total
times
Is π
Monte Carlo Method
Always Gives an answer
But not necessarily Correct
The probability of correctness goes up with time
Which Programming Paradigm is Best?
 Which of these paradigms is the best?
 The most accurate answer is that there is no best paradigm.
 No single paradigm will fit all problems well.
 Human beings use a combination of the models represented by these
paradigms.
 Languages with features from different paradigms are often too complex.
 So, the search of the ultimate programming language continues!
slide 81
Design Choices
• C: Efficient imperative programming with static types
• C++: Object-oriented programming with static types and
ad hoc, subtype and parametric polymorphism
• Java: Imperative, object-oriented, and concurrent
programming with static types and garbage collection
• Scheme: Lexically scoped, applicative-style recursive
programming with dynamic types
• Standard ML: Practical functional programming with strict
(eager) evaluation and polymorphic type inference
• Haskell: Pure functional programming with non-strict (lazy)
evaluation.
Imperative vs Non-Imperative
• Functional/Logic style clearly separates WHAT
aspects of a program (programmers’
responsibility) from the HOW aspects
(implementation decisions).
• An Imperative program contains both the
specification and the implementation details,
inseparably inter-twined.
Procedural vs Functional
• Program: a sequence of
instructions for a von
Neumann m/c.
• Computation by
instruction execution.
• Iteration.
• Modifiable or updatable
variables..
• Program: a collection of
function definitions
(m/c independent).
• Computation by term
rewriting.
• Recursion.
• Assign-only-once
variables.
Procedural vs Object-Oriented
• Emphasis on procedural
abstraction.
• Top-down design; Step-
wise refinement.
• Suited for programming
in the small.
• Emphasis on data
abstraction.
• Bottom-up design;
Reusable libraries.
• Suited for programming
in the large.

More Related Content

What's hot

Introduction to compiler
Introduction to compilerIntroduction to compiler
Introduction to compilerAbha Damani
 
Cyclomatic complexity
Cyclomatic complexityCyclomatic complexity
Cyclomatic complexity
Nikita Kesharwani
 
Software Reliability
Software ReliabilitySoftware Reliability
Software Reliability
ranapoonam1
 
testing strategies and tactics
 testing strategies and tactics testing strategies and tactics
testing strategies and tactics
Preeti Mishra
 
Software Testing
Software TestingSoftware Testing
Software Testing
Vishal Singh
 
Lexical analysis - Compiler Design
Lexical analysis - Compiler DesignLexical analysis - Compiler Design
Lexical analysis - Compiler Design
Muhammed Afsal Villan
 
Operating System PPT
Operating System PPTOperating System PPT
Operating System PPT
Rajneesh Chaubey
 
Decision Table Based Testing
Decision Table Based TestingDecision Table Based Testing
Decision Table Based Testing
Himani Solanki
 
Software Engineering - Ch1
Software Engineering - Ch1Software Engineering - Ch1
Software Engineering - Ch1Siddharth Ayer
 
Software Testing Fundamentals
Software Testing FundamentalsSoftware Testing Fundamentals
Software Testing FundamentalsChankey Pathak
 
White box testing
White box testingWhite box testing
White box testing
Neethu Tressa
 
Software Testing Strategies
Software Testing StrategiesSoftware Testing Strategies
Software Testing Strategies
NayyabMirTahir
 
Software myths | Software Engineering Notes
Software myths | Software Engineering NotesSoftware myths | Software Engineering Notes
Software myths | Software Engineering Notes
Navjyotsinh Jadeja
 
TESTING STRATEGY.ppt
TESTING STRATEGY.pptTESTING STRATEGY.ppt
TESTING STRATEGY.ppt
FawazHussain4
 
Behavioural modelling
Behavioural modellingBehavioural modelling
Behavioural modelling
Benazir Fathima
 
Testing Tools
Testing ToolsTesting Tools
Testing Tools
Ted Husted
 
Web Application Design
Web Application DesignWeb Application Design
Web Application Design
Hemin Patel
 
Programming Paradigm & Languages
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & Languages
Gaditek
 
Software Process Models
Software Process ModelsSoftware Process Models
Software Process Models
Hassan A-j
 

What's hot (20)

Introduction to compiler
Introduction to compilerIntroduction to compiler
Introduction to compiler
 
Cyclomatic complexity
Cyclomatic complexityCyclomatic complexity
Cyclomatic complexity
 
Software Reliability
Software ReliabilitySoftware Reliability
Software Reliability
 
testing strategies and tactics
 testing strategies and tactics testing strategies and tactics
testing strategies and tactics
 
Software Testing
Software TestingSoftware Testing
Software Testing
 
Lexical analysis - Compiler Design
Lexical analysis - Compiler DesignLexical analysis - Compiler Design
Lexical analysis - Compiler Design
 
Operating System PPT
Operating System PPTOperating System PPT
Operating System PPT
 
Decision Table Based Testing
Decision Table Based TestingDecision Table Based Testing
Decision Table Based Testing
 
Software Engineering - Ch1
Software Engineering - Ch1Software Engineering - Ch1
Software Engineering - Ch1
 
Software Testing Fundamentals
Software Testing FundamentalsSoftware Testing Fundamentals
Software Testing Fundamentals
 
White box testing
White box testingWhite box testing
White box testing
 
Software Testing Strategies
Software Testing StrategiesSoftware Testing Strategies
Software Testing Strategies
 
Software myths | Software Engineering Notes
Software myths | Software Engineering NotesSoftware myths | Software Engineering Notes
Software myths | Software Engineering Notes
 
TESTING STRATEGY.ppt
TESTING STRATEGY.pptTESTING STRATEGY.ppt
TESTING STRATEGY.ppt
 
Behavioural modelling
Behavioural modellingBehavioural modelling
Behavioural modelling
 
Testing Tools
Testing ToolsTesting Tools
Testing Tools
 
Java
JavaJava
Java
 
Web Application Design
Web Application DesignWeb Application Design
Web Application Design
 
Programming Paradigm & Languages
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & Languages
 
Software Process Models
Software Process ModelsSoftware Process Models
Software Process Models
 

Viewers also liked

Programming Paradigms
Programming ParadigmsProgramming Paradigms
Programming Paradigms
Directi Group
 
Programming Paradigms Seminar 1
Programming Paradigms Seminar 1Programming Paradigms Seminar 1
Programming Paradigms Seminar 1neoxiuting
 
Programming Paradigms
Programming ParadigmsProgramming Paradigms
Programming ParadigmsLi SUN
 
Overview of programming paradigms
Overview of programming paradigmsOverview of programming paradigms
Overview of programming paradigms
David-Frelin Johnson
 
Unit1 principle of programming language
Unit1 principle of programming languageUnit1 principle of programming language
Unit1 principle of programming languageVasavi College of Engg
 
Lect 1. introduction to programming languages
Lect 1. introduction to programming languagesLect 1. introduction to programming languages
Lect 1. introduction to programming languagesVarun Garg
 
Programming paradigm
Programming paradigmProgramming paradigm
Programming paradigm
Bhavin Kamani
 
Software Evolution
Software EvolutionSoftware Evolution
Software Evolution
Md. Shafiuzzaman Hira
 
Software Evolution
Software EvolutionSoftware Evolution
Software Evolution
Michele Lanza
 
Declarative Programming & Algebraic Data Types from Django's perspective
Declarative Programming & Algebraic Data Types from Django's perspectiveDeclarative Programming & Algebraic Data Types from Django's perspective
Declarative Programming & Algebraic Data Types from Django's perspectiveMaxim Avanov
 
XKE - Programming Paradigms & Constructs
XKE - Programming Paradigms & ConstructsXKE - Programming Paradigms & Constructs
XKE - Programming Paradigms & Constructs
Nicolas Demengel
 
Open Source: A New Software Paradigm
Open Source: A New Software ParadigmOpen Source: A New Software Paradigm
Open Source: A New Software Paradigm
Ye Joo Park
 
CombinedFile OceTDS7235
CombinedFile OceTDS7235CombinedFile OceTDS7235
CombinedFile OceTDS7235Victor Bracht
 
Event and signal driven programming techniques
Event and signal driven programming techniquesEvent and signal driven programming techniques
Event and signal driven programming techniques
Elizabeth Smith
 
Variables and data types in C++
Variables and data types in C++Variables and data types in C++
Variables and data types in C++
Ameer Khan
 
A presentation on types of network
A presentation on types of networkA presentation on types of network
A presentation on types of network
SUSHANT RATHOR
 
Take On Terror
Take On TerrorTake On Terror
Take On Terror
Matthew Bonfante Horrox
 
Software Paradigms
Software ParadigmsSoftware Paradigms
Software Paradigms
Del Elson
 

Viewers also liked (20)

Programming Paradigms
Programming ParadigmsProgramming Paradigms
Programming Paradigms
 
Programming Paradigms Seminar 1
Programming Paradigms Seminar 1Programming Paradigms Seminar 1
Programming Paradigms Seminar 1
 
Programming Paradigms
Programming ParadigmsProgramming Paradigms
Programming Paradigms
 
Overview of programming paradigms
Overview of programming paradigmsOverview of programming paradigms
Overview of programming paradigms
 
Programming paradigms
Programming paradigmsProgramming paradigms
Programming paradigms
 
Unit1 principle of programming language
Unit1 principle of programming languageUnit1 principle of programming language
Unit1 principle of programming language
 
Lect 1. introduction to programming languages
Lect 1. introduction to programming languagesLect 1. introduction to programming languages
Lect 1. introduction to programming languages
 
Programming paradigm
Programming paradigmProgramming paradigm
Programming paradigm
 
Software Evolution
Software EvolutionSoftware Evolution
Software Evolution
 
Software Evolution
Software EvolutionSoftware Evolution
Software Evolution
 
TYPES OF Paradigm
TYPES OF ParadigmTYPES OF Paradigm
TYPES OF Paradigm
 
Declarative Programming & Algebraic Data Types from Django's perspective
Declarative Programming & Algebraic Data Types from Django's perspectiveDeclarative Programming & Algebraic Data Types from Django's perspective
Declarative Programming & Algebraic Data Types from Django's perspective
 
XKE - Programming Paradigms & Constructs
XKE - Programming Paradigms & ConstructsXKE - Programming Paradigms & Constructs
XKE - Programming Paradigms & Constructs
 
Open Source: A New Software Paradigm
Open Source: A New Software ParadigmOpen Source: A New Software Paradigm
Open Source: A New Software Paradigm
 
CombinedFile OceTDS7235
CombinedFile OceTDS7235CombinedFile OceTDS7235
CombinedFile OceTDS7235
 
Event and signal driven programming techniques
Event and signal driven programming techniquesEvent and signal driven programming techniques
Event and signal driven programming techniques
 
Variables and data types in C++
Variables and data types in C++Variables and data types in C++
Variables and data types in C++
 
A presentation on types of network
A presentation on types of networkA presentation on types of network
A presentation on types of network
 
Take On Terror
Take On TerrorTake On Terror
Take On Terror
 
Software Paradigms
Software ParadigmsSoftware Paradigms
Software Paradigms
 

Similar to Paradigms

Plc part 1
Plc part 1Plc part 1
Plc part 1
Taymoor Nazmy
 
P1 2018 python
P1 2018 pythonP1 2018 python
P1 2018 python
Prof. Wim Van Criekinge
 
2016 bioinformatics i_python_part_1_wim_vancriekinge
2016 bioinformatics i_python_part_1_wim_vancriekinge2016 bioinformatics i_python_part_1_wim_vancriekinge
2016 bioinformatics i_python_part_1_wim_vancriekinge
Prof. Wim Van Criekinge
 
2015 bioinformatics python_introduction_wim_vancriekinge_vfinal
2015 bioinformatics python_introduction_wim_vancriekinge_vfinal2015 bioinformatics python_introduction_wim_vancriekinge_vfinal
2015 bioinformatics python_introduction_wim_vancriekinge_vfinal
Prof. Wim Van Criekinge
 
Are High Level Programming Languages for Multicore and Safety Critical Conver...
Are High Level Programming Languages for Multicore and Safety Critical Conver...Are High Level Programming Languages for Multicore and Safety Critical Conver...
Are High Level Programming Languages for Multicore and Safety Critical Conver...
InfinIT - Innovationsnetværket for it
 
Relation between Languages, Machines and Computations
Relation between Languages, Machines and ComputationsRelation between Languages, Machines and Computations
Relation between Languages, Machines and Computations
BHARATH KUMAR
 
Evolution of Programming Languages.pdf
Evolution of Programming Languages.pdfEvolution of Programming Languages.pdf
Evolution of Programming Languages.pdf
Madurai Kamaraj University Madurai Tamil Nadu India
 
Evolution of Programming Languages.pdf
Evolution of Programming Languages.pdfEvolution of Programming Languages.pdf
Evolution of Programming Languages.pdf
Madurai Kamaraj University Madurai Tamil Nadu India
 
Imperative programming
Imperative programmingImperative programming
Imperative programming
Edward Blurock
 
02paradigms.ppt
02paradigms.ppt02paradigms.ppt
02paradigms.ppt
ansariparveen06
 
Programing paradigm &amp; implementation
Programing paradigm &amp; implementationPrograming paradigm &amp; implementation
Programing paradigm &amp; implementation
Bilal Maqbool ツ
 
Mcs lec2
Mcs lec2Mcs lec2
Mcs lec2
Faiza Gull
 
Антон Кириллов, ZeptoLab
Антон Кириллов, ZeptoLabАнтон Кириллов, ZeptoLab
Антон Кириллов, ZeptoLab
Diana Dymolazova
 
computer programming C++
computer  programming C++computer  programming C++
computer programming C++
syedibrahimkaliba
 
LP1_educationeducationeducationeducation
LP1_educationeducationeducationeducationLP1_educationeducationeducationeducation
LP1_educationeducationeducationeducation
aicydacutanan627
 
On being a professional software developer
On being a professional software developerOn being a professional software developer
On being a professional software developer
Anton Kirillov
 
2. pl domain
2. pl domain2. pl domain
22_ideals.ppt
22_ideals.ppt22_ideals.ppt
22_ideals.ppt
DanielPerez457035
 
22_ideals (1).ppt
22_ideals (1).ppt22_ideals (1).ppt
22_ideals (1).ppt
Jadna Almeida
 

Similar to Paradigms (20)

Plc part 1
Plc part 1Plc part 1
Plc part 1
 
P1 2017 python
P1 2017 pythonP1 2017 python
P1 2017 python
 
P1 2018 python
P1 2018 pythonP1 2018 python
P1 2018 python
 
2016 bioinformatics i_python_part_1_wim_vancriekinge
2016 bioinformatics i_python_part_1_wim_vancriekinge2016 bioinformatics i_python_part_1_wim_vancriekinge
2016 bioinformatics i_python_part_1_wim_vancriekinge
 
2015 bioinformatics python_introduction_wim_vancriekinge_vfinal
2015 bioinformatics python_introduction_wim_vancriekinge_vfinal2015 bioinformatics python_introduction_wim_vancriekinge_vfinal
2015 bioinformatics python_introduction_wim_vancriekinge_vfinal
 
Are High Level Programming Languages for Multicore and Safety Critical Conver...
Are High Level Programming Languages for Multicore and Safety Critical Conver...Are High Level Programming Languages for Multicore and Safety Critical Conver...
Are High Level Programming Languages for Multicore and Safety Critical Conver...
 
Relation between Languages, Machines and Computations
Relation between Languages, Machines and ComputationsRelation between Languages, Machines and Computations
Relation between Languages, Machines and Computations
 
Evolution of Programming Languages.pdf
Evolution of Programming Languages.pdfEvolution of Programming Languages.pdf
Evolution of Programming Languages.pdf
 
Evolution of Programming Languages.pdf
Evolution of Programming Languages.pdfEvolution of Programming Languages.pdf
Evolution of Programming Languages.pdf
 
Imperative programming
Imperative programmingImperative programming
Imperative programming
 
02paradigms.ppt
02paradigms.ppt02paradigms.ppt
02paradigms.ppt
 
Programing paradigm &amp; implementation
Programing paradigm &amp; implementationPrograming paradigm &amp; implementation
Programing paradigm &amp; implementation
 
Mcs lec2
Mcs lec2Mcs lec2
Mcs lec2
 
Антон Кириллов, ZeptoLab
Антон Кириллов, ZeptoLabАнтон Кириллов, ZeptoLab
Антон Кириллов, ZeptoLab
 
computer programming C++
computer  programming C++computer  programming C++
computer programming C++
 
LP1_educationeducationeducationeducation
LP1_educationeducationeducationeducationLP1_educationeducationeducationeducation
LP1_educationeducationeducationeducation
 
On being a professional software developer
On being a professional software developerOn being a professional software developer
On being a professional software developer
 
2. pl domain
2. pl domain2. pl domain
2. pl domain
 
22_ideals.ppt
22_ideals.ppt22_ideals.ppt
22_ideals.ppt
 
22_ideals (1).ppt
22_ideals (1).ppt22_ideals (1).ppt
22_ideals (1).ppt
 

More from Edward Blurock

KEOD23-JThermodynamcsCloud
KEOD23-JThermodynamcsCloudKEOD23-JThermodynamcsCloud
KEOD23-JThermodynamcsCloud
Edward Blurock
 
BlurockPresentation-KEOD2023
BlurockPresentation-KEOD2023BlurockPresentation-KEOD2023
BlurockPresentation-KEOD2023
Edward Blurock
 
KEOD-2023-Poster.pptx
KEOD-2023-Poster.pptxKEOD-2023-Poster.pptx
KEOD-2023-Poster.pptx
Edward Blurock
 
ChemConnect: Poster for European Combustion Meeting 2017
ChemConnect: Poster for European Combustion Meeting 2017ChemConnect: Poster for European Combustion Meeting 2017
ChemConnect: Poster for European Combustion Meeting 2017
Edward Blurock
 
ChemConnect: SMARTCATS presentation
ChemConnect: SMARTCATS presentationChemConnect: SMARTCATS presentation
ChemConnect: SMARTCATS presentation
Edward Blurock
 
EU COST Action CM1404: WG€ - Efficient Data Exchange
EU COST Action CM1404: WG€ - Efficient Data ExchangeEU COST Action CM1404: WG€ - Efficient Data Exchange
EU COST Action CM1404: WG€ - Efficient Data Exchange
Edward Blurock
 
ChemConnect: Viewing the datasets in the repository
ChemConnect: Viewing the datasets in the repositoryChemConnect: Viewing the datasets in the repository
ChemConnect: Viewing the datasets in the repository
Edward Blurock
 
ChemConnect: Characterizing CombusAon KineAc Data with ontologies and meta-­‐...
ChemConnect: Characterizing CombusAon KineAc Data with ontologies and meta-­‐...ChemConnect: Characterizing CombusAon KineAc Data with ontologies and meta-­‐...
ChemConnect: Characterizing CombusAon KineAc Data with ontologies and meta-­‐...
Edward Blurock
 
Poster: Characterizing Ignition behavior through morphing to generic curves
Poster: Characterizing Ignition behavior through morphing to generic curvesPoster: Characterizing Ignition behavior through morphing to generic curves
Poster: Characterizing Ignition behavior through morphing to generic curves
Edward Blurock
 
Poster: Very Open Data Project
Poster: Very Open Data ProjectPoster: Very Open Data Project
Poster: Very Open Data Project
Edward Blurock
 
Poster: Adaptive On-­‐the-­‐fly Regression Tabula@on: Beyond ISAT
Poster: Adaptive On-­‐the-­‐fly Regression Tabula@on: Beyond ISATPoster: Adaptive On-­‐the-­‐fly Regression Tabula@on: Beyond ISAT
Poster: Adaptive On-­‐the-­‐fly Regression Tabula@on: Beyond ISAT
Edward Blurock
 
Characterization Ignition Behavior through Morphing to Generic Ignition Curves
Characterization Ignition Behavior through Morphing to Generic Ignition CurvesCharacterization Ignition Behavior through Morphing to Generic Ignition Curves
Characterization Ignition Behavior through Morphing to Generic Ignition Curves
Edward Blurock
 
Computability, turing machines and lambda calculus
Computability, turing machines and lambda calculusComputability, turing machines and lambda calculus
Computability, turing machines and lambda calculus
Edward Blurock
 
Programming Languages
Programming LanguagesProgramming Languages
Programming Languages
Edward Blurock
 
Relational algebra
Relational algebraRelational algebra
Relational algebra
Edward Blurock
 
Database normalization
Database normalizationDatabase normalization
Database normalization
Edward Blurock
 
Generalization abstraction
Generalization abstractionGeneralization abstraction
Generalization abstraction
Edward Blurock
 
Overview
OverviewOverview
Overview
Edward Blurock
 
Networks
NetworksNetworks
Networks
Edward Blurock
 
Computability and Complexity
Computability and ComplexityComputability and Complexity
Computability and Complexity
Edward Blurock
 

More from Edward Blurock (20)

KEOD23-JThermodynamcsCloud
KEOD23-JThermodynamcsCloudKEOD23-JThermodynamcsCloud
KEOD23-JThermodynamcsCloud
 
BlurockPresentation-KEOD2023
BlurockPresentation-KEOD2023BlurockPresentation-KEOD2023
BlurockPresentation-KEOD2023
 
KEOD-2023-Poster.pptx
KEOD-2023-Poster.pptxKEOD-2023-Poster.pptx
KEOD-2023-Poster.pptx
 
ChemConnect: Poster for European Combustion Meeting 2017
ChemConnect: Poster for European Combustion Meeting 2017ChemConnect: Poster for European Combustion Meeting 2017
ChemConnect: Poster for European Combustion Meeting 2017
 
ChemConnect: SMARTCATS presentation
ChemConnect: SMARTCATS presentationChemConnect: SMARTCATS presentation
ChemConnect: SMARTCATS presentation
 
EU COST Action CM1404: WG€ - Efficient Data Exchange
EU COST Action CM1404: WG€ - Efficient Data ExchangeEU COST Action CM1404: WG€ - Efficient Data Exchange
EU COST Action CM1404: WG€ - Efficient Data Exchange
 
ChemConnect: Viewing the datasets in the repository
ChemConnect: Viewing the datasets in the repositoryChemConnect: Viewing the datasets in the repository
ChemConnect: Viewing the datasets in the repository
 
ChemConnect: Characterizing CombusAon KineAc Data with ontologies and meta-­‐...
ChemConnect: Characterizing CombusAon KineAc Data with ontologies and meta-­‐...ChemConnect: Characterizing CombusAon KineAc Data with ontologies and meta-­‐...
ChemConnect: Characterizing CombusAon KineAc Data with ontologies and meta-­‐...
 
Poster: Characterizing Ignition behavior through morphing to generic curves
Poster: Characterizing Ignition behavior through morphing to generic curvesPoster: Characterizing Ignition behavior through morphing to generic curves
Poster: Characterizing Ignition behavior through morphing to generic curves
 
Poster: Very Open Data Project
Poster: Very Open Data ProjectPoster: Very Open Data Project
Poster: Very Open Data Project
 
Poster: Adaptive On-­‐the-­‐fly Regression Tabula@on: Beyond ISAT
Poster: Adaptive On-­‐the-­‐fly Regression Tabula@on: Beyond ISATPoster: Adaptive On-­‐the-­‐fly Regression Tabula@on: Beyond ISAT
Poster: Adaptive On-­‐the-­‐fly Regression Tabula@on: Beyond ISAT
 
Characterization Ignition Behavior through Morphing to Generic Ignition Curves
Characterization Ignition Behavior through Morphing to Generic Ignition CurvesCharacterization Ignition Behavior through Morphing to Generic Ignition Curves
Characterization Ignition Behavior through Morphing to Generic Ignition Curves
 
Computability, turing machines and lambda calculus
Computability, turing machines and lambda calculusComputability, turing machines and lambda calculus
Computability, turing machines and lambda calculus
 
Programming Languages
Programming LanguagesProgramming Languages
Programming Languages
 
Relational algebra
Relational algebraRelational algebra
Relational algebra
 
Database normalization
Database normalizationDatabase normalization
Database normalization
 
Generalization abstraction
Generalization abstractionGeneralization abstraction
Generalization abstraction
 
Overview
OverviewOverview
Overview
 
Networks
NetworksNetworks
Networks
 
Computability and Complexity
Computability and ComplexityComputability and Complexity
Computability and Complexity
 

Recently uploaded

Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 

Recently uploaded (20)

Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 

Paradigms

  • 1. PROGRAMMING PARADIGMS Cooperative Information Systems Edward Blurock Programming Paradigms Introduction CIS: Edward Blruock
  • 2. Why are there so many programming languages? Lecture: Programming Paradigm programming CIS: Edward Blruock Human Computer Interface The Program
  • 3. Why are there so many programming languages? Lecture: Programming Paradigm programming CIS: Edward Blruock Historically, the first programs were close to the computer level The Program The Program The Program Human Computer Interface But as programming languages are evolving Organizational structure are becoming more human
  • 4. Lecture: Programming Paradigm CIS: Edward Blruock Why are there so many programming languages? The Program Mathematical concepts The computer Organizational Concepts: Program flow, data organization What influences program language design?
  • 5. FORMAL BASIS OF PROGRAMMING LANGUAGES Mathematical Basis Lecture: Programming Paradigm CIS: Edward Blruock
  • 6. Algorithm slide 6 • Abu Ja’far Muhammad ibn Musa al-Khorezmi (“from Khorezm”) – Lived in Baghdad around 780 – 850 AD – Chief mathematician in Khalif Al Mamun’s “House of Wisdom” – Author of “A Compact Introduction To Calculation Using Rules Of Completion And Reduction” Removing negative units from the equation by adding the same quantity on the other side (“al- gabr” in Arabic)
  • 7. slide 7 “Calculus of Thought” • Gottfried Wilhelm Leibniz – 1646 - 1716 – Inventor of calculus and binary system – “Calculus ratiocinator” human reasoning can be reduced to a formal symbolic language, in which all arguments would be settled by mechanical manipulation of logical concepts – Invented a mechanical calculator
  • 8. slide 8 Formalisms for Computation (1) • Predicate logic – Gottlöb Frege (1848-1925) – Formal basis for proof theory and automated theorem proving – Logic programming • Computation as logical deduction • Turing machines – Alan Turing (1912-1954) – Imperative programming • Sequences of commands, explicit state transitions, update via assignment
  • 9. slide 9 Formalisms for Computation (2) • Lambda calculus – Alonzo Church (1903-1995) – Formal basis for all functional languages, semantics, type theory – Functional programming • Pure expression evaluation, no assignment operator • Recursive functions & automata – Stephen Kleene (1909-1994) – Regular expressions, finite-state machines, PDAs
  • 10. slide 10 Programming Language • Formal notation for specifying computations – Syntax (usually specified by a context-free grammar) – Semantics for each syntactic construct – Practical implementation on a real or virtual machine • Translation vs. compilation vs. interpretation – C++ was originally translated into C by Stroustrup’s Cfront – Java originally used a bytecode interpreter, now native code compilers are commonly used for greater efficiency – Lisp, Scheme and most other functional languages are interpreted by a virtual machine, but code is often precompiled to an internal executable for efficiency • Efficiency vs. portability
  • 11. slide 11 Computability • Function f is computable if some program P computes it – For any input x, the computation P(x) halts with output f(x) – Partial recursive functions: partial functions (int to int) that are computable
  • 12. slide 12 Halting Problem Ettore Bugatti: "I make my cars to go, not to stop"
  • 13. slide 13 Program Correctness • Assert formal correctness statements about critical parts of a program and reason effectively – A program is intended to carry out a specific computation, but a programmer can fail to adequately address all data value ranges, input conditions, system resource constraints, memory limitations, etc. • Language features and their interaction should be clearly specified and understandable – If you do not or can not clearly understand the semantics of the language, your ability to accurately predict the behavior of your program is limited
  • 14. slide 14 Billion-Dollar Mistake Failed launch of Ariane 5 rocket (1996) – $500 million payload; $7 billion spent on development Cause: software error in inertial reference system – Re-used Ariane 4 code, but flight path was different – 64-bit floating point number related to horizontal velocity converted to 16-bit signed integer; the number was larger than 32,767; inertial guidance crashed
  • 16. First modern computer – first compiler  David Wheeler (1927-2004)  University of Cambridge  Exceptional problem solver: hardware, software, algorithms, libraries  First computer science Ph.D. (1951)  First paper on how to write correct, reusable, and maintainable code (1951)  (Thesis advisor for Bjarne Stroustrup ) 16Stroustrup/Programming
  • 17. slide 17 Assembly Languages • Invented by machine designers the early 1950s • Mnemonics instead of binary opcodes push ebp mov ebp, esp sub esp, 4 push edi • Reusable macros and subroutines
  • 18. slide 18 FORTRAN • Procedural, imperative language – Still used in scientific computation • Developed at IBM in the 1950s by John Backus (1924-2007) – Backus’s 1977 Turing award lecture (see course website) made the case for functional programming – On FORTRAN: “We did not know what we wanted and how to do it. It just sort of grew. The first struggle was over what the language would look like. Then how to parse expressions – it was a big problem…” • BNF: Backus-Naur form for defining context-free grammars
  • 19. slide 19 LISP • Invented by John McCarthy (b. 1927, Turing award: 1971) – See original paper on course website • Formal notation for lambda-calculus • Pioneered many PL concepts – Automated memory management (garbage collection) – Dynamic typing – No distinction between code and data • Still in use: ACL2, Scheme, …
  • 20. slide 20 Algol 60 • Designed in 1958-1960 • Great influence on modern languages – Formally specified syntax (BNF) • Peter Naur: 2005 Turing award – Lexical scoping: begin … end or {…} – Modular procedures, recursive procedures, variable type declarations, stack storage allocation • “Birth of computer science” -- Dijkstra • “A language so far ahead of its time that it was not only an improvement on its predecessors, but also on nearly all its successors” -- Hoare
  • 21. slide 21 Algol 60 Sample real procedure average(A,n); real array A; integer n; begin real sum; sum := 0; for i = 1 step 1 until n do sum := sum + A[i]; average := sum/n end; no ; here no array bounds set procedure return value by assignment
  • 22. Simula 67 • Kristen Nygaard (1926-2002) and Ole-Johan Dahl (1931-2002) – Norwegian Computing Center – Oslo University – The start of object-oriented programming and object-oriented design 22Stroustrup/Programming
  • 23. slide 23 Pascal • Designed by Niklaus Wirth – 1984 Turing Award • Revised type system of Algol – Good data structure concepts • Records, variants, subranges – More restrictive than Algol 60/68 • Procedure parameters cannot have procedure parameters • Popular teaching language • Simple one-pass compiler
  • 24. slide 24 C • Bell Labs 1972 (Dennis Ritchie) • Development closely related to UNIX – 1983 Turing Award to Thompson and Ritchie • Added weak typing to B – int, char, their pointer types – Typed arrays = typed pointers • int a[10]; … x = a[i]; means x = *(&a[0]+i*sizeof(int)) • Compiles to native code
  • 25. slide 25 C++ • Bell Labs 1979 (Bjarne Stroustrup) – “C with Classes” (C++ since 1983) • Influenced by Simula • Originally translated into C using Cfront, then native compilers – GNU g++ • Several PL concepts – Multiple inheritance – Templates / generics – Exception handling
  • 26. slide 26 Java • Sun 1991-1995 (James Gosling) – Originally called Oak, intended for set top boxes • Mixture of C and Modula-3 – Unlike C++ • No templates (generics), no multiple inheritance, no operator overloading – Like Modula-3 (developed at DEC SRC) • Explicit interfaces, single inheritance, exception handling, built-in threading model, references & automatic garbage collection (no explicit pointers!) • “Generics” added later
  • 27. slide 27 Why So Many Languages? “There will always be things we wish to say in our programs that in all languages can only be said poorly.” - Alan Perlis
  • 28. slide 28 What’s Driving Their Evolution? • Constant search for better ways to build software tools for solving computational problems – Many PLs are general purpose tools – Others are targeted at specific kinds of problems • For example, massively parallel computations or graphics • Useful ideas evolve into language designs – Algol  Simula  Smalltalk  C with Classes  C++ • Often design is driven by expediency – Scripting languages: Perl, Tcl, Python, PHP, etc. • “PHP is a minor evil perpetrated by incompetent amateurs, whereas Perl is a great and insidious evil, perpetrated by skilled but perverted professionals.” - Jon Ribbens
  • 29. slide 29 What Do They Have in Common? • Lexical structure and analysis – Tokens: keywords, operators, symbols, variables – Regular expressions and finite automata • Syntactic structure and analysis – Parsing, context-free grammars • Pragmatic issues – Scoping, block structure, local variables – Procedures, parameter passing, iteration, recursion – Type checking, data structures • Semantics – What do programs mean and are they correct
  • 30. slide 30 Core Features vs. Syntactic Sugar • What is the core high-level language syntax required to emulate a universal Turing machine? – What is the core syntax of C? • Are ++, --, +=, -=, ?:, for/do/while part of the core? • Convenience features? – Structures/records, arrays, loops, case/switch? – Preprocessor macros (textual substitution) – Run-time libraries • String handling, I/O, system calls, threads, networking, etc. – “Syntactic sugar causes cancer of the semicolons” - Alan Perlis
  • 31. slide 31 Where Do Paradigms Come From? • Paradigms emerge as the result of social processes in which people develop ideas and create principles and practices that embody those ideas – Thomas Kuhn. “The Structure of Scientific Revolutions.” • Programming paradigms are the result of people’s ideas about how programs should be constructed – … and formal linguistic mechanisms for expressing them – … and software engineering principles and practices for using the resulting programming language to solve problems
  • 32. Paradigms • Programming paradigm is a fundamental style of computer programming • Paradigms differ in concepts and abstractions used to represent the elements of program
  • 33. Paradigms v1.0 © 2007 by Peter Van Roy Turing equivalent Data structures only (channel) + port (state) + cell Java, OCaml + cell (state) Event−loop programming Sequential object−oriented programming Stateful functional programming Functional programming First−order programming + procedure functional + nondeterministic FGHC, FCP, + name Encapsulated functional programming + closure Pascal, C, Imperative programming Prolog Scheme, ML constraint Prolog, SQL + search + solver Constraint (logic) programming Concurrent (equality) + thread Lazy constraint programming programming Relational & logic Deterministic logic programming + unification LIFE, AKL programming (FRP) CLP, ILOG Solver Weak state StatefulNo state constraints Logic and Functional Message passing + closure programming Nonmonotonic programming dataflow Concurrent logic programming Oz, Alice, AKL dataflow programming (channel) + port Multi−agent Shared state Functional reactive FrTime + by−need synchronization + synchronization on partial termination choice CLU, E, Oz (unforgeable constant) + thread declarative Lazy programming dataflow programming + single assignment Lazy concurrent Lazy functional synchron. + by−need programming + thread + single assign. programming concurrent Haskell Monotonic dataflow programming Declarative Unix pipes + by−need synchronization Oz, Alice, AKL + local cell programming Active object Object−capability programming publish/subscribe, E, Oz, Alice, tuple space (Linda) Erlang, AKL + thread Multi−agent programming Message−passing concurrent programming Oz, Alice Java, Oz, Shared−state concurrent programming object−oriented Concurrent programming + thread Alice Oz, Alice Dataflow and message passing The principal programming paradigms "More is not better (or worse) than less, just different." Each language is placed next to a programming paradigm it supports well. Inspired by "Concepts, Techniques, and Models of Computer Programming." + log Software transactional memory (STM) SQL record declarative programming XML Descriptive Lecture: Programming Paradigm Overview CIS: Edward Blruock
  • 34. Major Paradigms • Imperative • Functional • Declarative • Object Oriented • Event-Driven • Stochastic There are many ways to categorize programming paradigms. It should also be said that they are not mutually exclusive. Lecture: Programming Paradigm Overview CIS: Edward Blruock
  • 36. Imperative Programming • Derived from latin word imperare means “to command” • It is based on commands that update variables in storage • Is a programming paradigm that describes computation in terms of statements that change a program state.
  • 37. Contd.. • It defines sequences of commands for the computer to perform • Imperative programming is characterized by programming with a state and commands
  • 38. Contd.. • In imperative programming, a name may be assigned to a value and later reassigned to another value. • A name is tied to two bindings, a binding to a location and to a value. • The location is called the l-value and the value is called the r-value.
  • 39. Contd.. • For example, – X := X+2 • Assignment changes the value at a location. • A program execution generates a sequence of states
  • 40. Unstructured Commands • The unstructured commands contains: – assignment command, – sequential composition of commands, – a provision to identify a command with a label, – unconditional and conditional GOTO commands
  • 41. L-value and r-value • l-value: address/location – lifetime – memory allocation • r-value: contents/encoded value – initialization – constants * binding
  • 42. Iteration • For statement – Loop control variable • The while loop • while vs do-while • do-while versus repeat-until • Iteration using goto
  • 43. Goto statement Loops a GOTO (or similar) statement The GOTO jumps to a specified location (label or address) n!º i i=1 n Õ an index involved The index is incremented until the end is reached i=1 factorial = 1; loop: factorial = factorial * I if( i=n) goto exit goto loop exit
  • 44. Structured Programming • The goal of structured programming is to provide control structures that make it easier to reason about imperative programs.
  • 45. Contd.. • an IF statement corresponds to an If condition then command and a DO statement corresponds to a While condition Do command. – IF guard --> command FI=if guard then command – DO guard --> command OD=while guard do command
  • 46. Iteration Repetition of a block of code n!º i i=1 n Õ an index involved The index is incremented until the end is reached i=1 factorial = 1; while( i <= n) { factorial = factorial * i i = i + 1 } Once again involves a iteration counter factorial = 1; for i=1 to n { factorial = factorial * I }
  • 47. Programming Paradigms: Functional  A program in this paradigm consists of functions and uses functions in a similar way as used in mathematics Program execution involves functions calling each other and returning results. There are no variables in functional languages.  Example functional languages include: ML, MirandaTM, Haskell  Advantages Small and clean syntax Better support for reasoning about programs They allow functions to be treated as any other data values. They support programming at a relatively higher level than the imperative languages  Disadvantages Difficulty of doing input-output Functional languages use more storage space than their imperative cousins
  • 48. Possible Benefits • The ability to re-use the same code at different places in the program without copying it. • An easier way to keep track of program flow than a collection of "GOTO" or "JUMP" statements
  • 49. Functional Programming • It treats computation as the evaluation of mathematical functions and avoids state and mutable data. • It emphasizes the application of functions, in contrast to the imperative programming style
  • 51. Content of Recursion • Base case(s). o Values of the input variables for which we perform no recursive calls are called base cases (there should be at least one base case). o Every possible chain of recursive calls must eventually reach a base case. • Recursive calls. o Calls to the current method. o Each recursive call should be defined so that it makes progress towards a base case. factorial(n) { if(n=1) return 1 return factorial(n-1)*n } n!º 1 n =1 n*(n-1)! n >1 ì í ï îï ü ý ï þï
  • 52. How do I write a recursive function? • Determine the size factor o The number: smaller number, smaller size • Determine the base case(s) o The case for n=1, the answer is 1 • Determine the general case(s) o The recursive call: factorial(n)=factorial(n-1)*n • Verify the algorithm (use the "Three-Question-Method") factorial(n) { if(n=1) return 1 return factorial(n-1)*n } n!º 1 n =1 n*(n-1)! n >1 ì í ï îï ü ý ï þï
  • 53. Three-Question Verification Method 1. The Base-Case Question: Is there a nonrecursive way out of the function, and does the routine work correctly for this "base" case? 2. The Smaller-Caller Question: Does each recursive call to the function involve a smaller case of the original problem, leading inescapably to the base case? 3. The General-Case Question: Assuming that the recursive call(s) work correctly, does the whole function work correctly?
  • 54. Stacks in recursion factorial(n) If (n=1) return 1 else return factorial(n-1) n! = n*(n-1)*(n-2)*(n-3)*……* 1 5! = 5*4*3*2*1 Factorial(5) Factorial(4) Factorial(3) Factorial(2) Factorial(1) return 1 Return 2 Return 6 Return 24 Return 120 5!=120 Deep recursion can result in running out of memory
  • 56. Declarative Programming Not a recipe Does not explicitly list command or steps that need to be carried out to achieve the results. Set of Declarations separates the process of stating a problem from the process of solving the problem. The domain is described through a set of declarations An external “engine” interprets these declarations to perform a task
  • 57. Programmed Behavior Lecture: Programming Paradigm Declarative CIS: Edward Blruock Digger Wasps are predators that can sting and paralyze prey insects. They construct a protected “nest and then stock it with captured insects. The wasps lay their eggs in the provisioned nest. When the wasp larvae hatch, they feed on the paralyzed insects. 1. Dig nest 2. Place paralyzed insect at nest entrance 3. Go in and inspect nest 4. Come out 5. Take paralyzed insect in nest
  • 58. Programmed Behavior Lecture: Programming Paradigm Declarative CIS: Edward Blruock 1. Dig nest 2. Place paralyzed insect at nest entrance 3. Go in and inspect nest 4. Come out 5. Take paralyzed insect in nest If during step 3, when the insect is inside the nest, the researcher removes the insect The insect will go back to step 2, retrieve the insect and, again step 3, inspect the nest.
  • 59. Programmed Behavior Lecture: Programming Paradigm Declarative CIS: Edward Blruock 1. Dig nest 2. Place paralyzed insect at nest entrance 3. Go in and inspect nest 4. Come out 5. Take paralyzed insect in nest Imperative View: A recipe, step 1, before step 2, before step 3…. Fixed programming can lead to (unexpected) problems.
  • 60. Declarative Paradigm Lecture: Programming Paradigm Declarative CIS: Edward Blruock Not a recipe for the computer Imperative programming Declarative Programming Computer Sets up a set of (reactive) states Engine “Recipe” Built (compiled) Directly in Computer States are managed By an “engine” Built (compiled) Directly in Computer
  • 61. Declarative programming Expresses the logic of a computation without describing its control flow. n!º 1 n =1 n*(n-1)! n >1 ì í ï îï ü ý ï þï factorial(1,1) factorial(N,F) :- N1 is N-1, factorial(N1,F1),F is N*F1. The problem is (mathematically) described The engine takes care of the solving/using the description Solving predicate logic is the engine
  • 62. Declarative Programming Lecture: Programming Paradigm Declarative Programming CIS: Edward Blruock PROLOG: Horn clause predicate: P(X,Y,…) := Condition1(…), Condition2(…), .... If these conditions are true, then the predicate is true Backward chaining: examine conditions to determine truth of predicate (p ∧ q ∧ ... ∧ t) → u
  • 63. Rules • Consider the following sentence : – 'All men are mortal' • We can express this as : – mortal(X) :- human(X). • Let us define the fact that Socrate is a human. – mortal(X) :- human(X). human(socrate).
  • 64. Contd.. • Now if we ask to prolog : – ?- mortal(socrate). • What prolog will respond ? • Why ?
  • 65. Constraint Logic Programming factorial(1,1) factorial(N,F) :- N1 is N-1, factorial(N1,F1),F is N*F1. Factorial(5,F) Returns F=120 Factorial(N.120) Creates an instantiation error PROLOG has no knowledge of Real or Integer numbers Mathematical manipulations cannot be made
  • 66. Constraint Logic Programming factorial(1,1) factorial(N,F) :- N1 is N-1, factorial(N1,F1),F is N*F1. Logic Programming Constraint Logic Programming CLP Formulas passed to CLP Reduced or solved formulas returned Mathmatical knowledge about the numbers used
  • 67. Declarative Programming 9/15/2015 67 Subclass: Reactive systems Response to a set of conditions Declaration: 1. The set of conditions 2. The response
  • 68. Declarative Programming Lecture: Programming Paradigm Declarative Programming CIS: Edward Blruock Expert Systems (is the engine): A set of rules. The rule executes if the conditions hold. Rules: 1. If X croaks and eats flies - Then X is a frog 2. If X chirps and sings - Then X is a canary 3. If X is a frog - Then X is green 4. If X is a caary - Then X is yellow 1. Fritz croaks and Fritz eats flies Based on logic, the computer can derive: 2. Fritz croaks and eats flies Based on rule 1, the computer can derive: 3. Fritz is a frog Based on rule 3, the computer can derive: 4. Fritz is green. Facts 1. Fritz croaks 2. Fritz eats flies
  • 69. Declarative Programming Lecture: Programming Paradigm Declarative Programming CIS: Edward Blruock GUI Interface: An action, activated by conditions, produces a response. Don’t Press Action The System Explodes! Response
  • 70. Declarative Programming Lecture: Programming Paradigm Declarative Programming CIS: Edward Blruock System of agents (on the internet): An agent responds, if it sees the right conditions. Agent Agent Agent Agent Agent Agent Agent
  • 71. Declarative Programming Lecture: Programming Paradigm Declarative Programming CIS: Edward Blruock Environment Declaration Engine PROLOG Horn Clause Predicate Logic: Backward chaining Expert System A rule or fact Expert System: Forward chaining GUI An action function GUI/Operating system System of Agents Program within agent Internet message passing
  • 72. Contd.. • It is a paradigm where we focus real life objects while programming any solution. • We actually write behaviours of our programming objects, those behaviours are called methods in objected oriented programming.
  • 73. Principal advantage • They enable programmers to create modules that do not need to be changed when a new type of object is added. • A programmer can simply create a new object that inherits many of its features from existing objects.
  • 74. Fundamental Concepts • Class • Object • Instance • Method • Message passing • Inheritance • Abstraction • Encapsulation • Polymorphism • Decoupling
  • 75. Main features • Encapsulation: – a logical boundary around methods and properties • Inheritance • Re-usability – method overloading and overriding • Information Hiding – is achieved through "Access Modifiers"
  • 76. Probabilistic Algorithms Non-deterministic No exact control program flow Leaves Some of Its Decisions To Chance Outcome of the program in different runs is not necessarily the same Monte Carlo Methods Always Gives an answer But not necessarily Correct The probability of correctness go es up with time Las Vegas Methods Never returns an incorrect answer But sometimes it doesn’t give an answer
  • 77. Probabilistic Algorithms Probabilistic Algorithms in optimization: Closer to human reasoning and problem solving (for hard problems we don’t follow strict deterministic algorithms) Finding local and global minimum
  • 78. Probabilistic Algorithms Classic gradient optimization find local minimum The search path is always downhill toward minimum Probabilistic algorithms allow search to go uphill sometimes Randomness in the search for next step Genetic Algorithms Simulated Annealing to find global minimum
  • 79. Probabilistic Algorithms Calculate pi with a dart board Area of square d2 Area of Circle: P d 2 æ è ç ö ø ÷ 2 prob = circle square = p d 2 æ è ç ö ø ÷ 2 d2 = p 4 Probability dart will be in circle d number darts in circle divided by number of darts in total times Is π Monte Carlo Method Always Gives an answer But not necessarily Correct The probability of correctness goes up with time
  • 80. Which Programming Paradigm is Best?  Which of these paradigms is the best?  The most accurate answer is that there is no best paradigm.  No single paradigm will fit all problems well.  Human beings use a combination of the models represented by these paradigms.  Languages with features from different paradigms are often too complex.  So, the search of the ultimate programming language continues!
  • 81. slide 81 Design Choices • C: Efficient imperative programming with static types • C++: Object-oriented programming with static types and ad hoc, subtype and parametric polymorphism • Java: Imperative, object-oriented, and concurrent programming with static types and garbage collection • Scheme: Lexically scoped, applicative-style recursive programming with dynamic types • Standard ML: Practical functional programming with strict (eager) evaluation and polymorphic type inference • Haskell: Pure functional programming with non-strict (lazy) evaluation.
  • 82. Imperative vs Non-Imperative • Functional/Logic style clearly separates WHAT aspects of a program (programmers’ responsibility) from the HOW aspects (implementation decisions). • An Imperative program contains both the specification and the implementation details, inseparably inter-twined.
  • 83. Procedural vs Functional • Program: a sequence of instructions for a von Neumann m/c. • Computation by instruction execution. • Iteration. • Modifiable or updatable variables.. • Program: a collection of function definitions (m/c independent). • Computation by term rewriting. • Recursion. • Assign-only-once variables.
  • 84. Procedural vs Object-Oriented • Emphasis on procedural abstraction. • Top-down design; Step- wise refinement. • Suited for programming in the small. • Emphasis on data abstraction. • Bottom-up design; Reusable libraries. • Suited for programming in the large.