0% found this document useful (0 votes)
10 views30 pages

G4 Chapter 3 2019

Uploaded by

SHIMELS
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views30 pages

G4 Chapter 3 2019

Uploaded by

SHIMELS
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 30

Chapter 1

Programming Paradigms

Prof DP Sharma
http://dpsharma.info
Course Outline
Programming Paradigms-
Introduction to Machine
Procedural,
Object Oriented.
New Paradigms like-
Logic Programming,
Knowledge based Programming
and
Symbolic Programming etc.
Definitions
 In science and philosophy, a paradigm is a
distinct set of concepts or thought patterns,
including theories, research methods, postulates,
and standards for what constitutes legitimate
contributions to a field.
 What is Programming Paradigm?
 programming “technique” (?)
 way of thinking about programming
 view of a program
 Programming Language
 consists of words, symbols, and rules for
writing a program
Paradigm?
 Thomas Kuhn (The Structure of Scientific
Revolutions): "… accepted samples of
practical methods in science.”
 Willis Hartman (An Incomplete Guide to
the Future): "… a basic way of
perceiving, thinking, valuing and
doing things that are associated with a
particular vision of reality.”
 Marilyn Ferguson (The Aquarian
Conspiracy): "… a framework for
thought… a scheme for understanding
and explaining certain aspects of reality."
Definition of programming
paradigm
“A programming paradigm is a
fundamental smartness or
style of computer programming,
that leads as a new style of building
computer programs. “ Definition by
Prof. DP Sharma http://dpsharma.info
Capabilities and styles of
various programming languages are
influenced by one paradigm or more
than one paradigms.
The Paradigm Shift ?
A paradigm shift, as identified by
American physicist Thomas Kuhn, is a
fundamental change in the basic
concepts and experimental practices of
a scientific discipline. (Source: WIKI)
A Paradigm Shift as a change from one
way of thinking to another. It's a
revolution, a transformation, a sort of
metamorphosis. It just does not
happen, but rather it is driven by
agents of change.
The Paradigm Shift (cont’d)
 Examples (specific to computing):
• Structured programming. Example C, Pascal
• Object oriented programming. Example C++,
Java
• The WWW.
• The .Com boom
• Computing in Astronomy.
• Cloud Computing
• IoT
 NOTES:
• Paradigm shifts occur suddenly.
• Their timing is VERY difficult to predict.
Contd…
Imperative paradigm- First do
this and next
Functional paradigm - do that
Evaluate an
expression and use
the resulting value
for something
Logic paradigm- Answer a
question via
search for a

Object-oriented paradigm- solution


Send messages
between objects to
simulate the
temporal evolution of
a set of real world
phenomena
Imperative paradigm-
The 'first do this, next do that' is a
short phrase which really in a nutshell
describes the spirit of the imperative
paradigm. The basic idea is the
command, which has a measurable
effect on the program state.

The phrase also reflects that the order


to the commands is important. 'First
do that, and then do this' would be
different from 'first do this, and
then do that'.
Functional paradigm
Functional programming is in many
respects a simpler and more clean
programming paradigm than the
imperative one.
The reason is that the paradigm
originates from a purely
mathematical discipline: the
theory of functions.
Functional Programming: History
 Functional programming has its roots in the lambda calculus, a
formal system developed in the 1930s to investigate function definition,
function application, and recursion.
 LISP was the first operational functional programming language.

 Up to this day, functional programming has not been very popular except
for a restricted number of application areas, such as artificial
intelligence.
 John Backus presented the FP programming language in his 1977 Turing
Award lecture "Can Programming Be Liberated From the von Neumann
Style? A Functional Style and its Algebra of Programs".
 Widespread declarative domain-specific languages like SQL and
Lex/Yacc, use some elements of functional programming, especially in
eschewing mutable values. Spreadsheets can also be viewed as
functional programming languages.11
Logic paradigm
The logic paradigm is dramatically
different from the other three main
programming paradigms.
The logic paradigm fits extremely well
when applied in problem domains
that deal with the extraction of
knowledge from basic facts and
relations
Object Oriented paradigm
The primary and most direct reason is
undoubtedly the strong support of
encapsulation and the logical
grouping of program aspects.
These properties are very important
when programs become larger and
larger
Object-oriented
programming
Later, object-oriented languages
(like Simula, Smalltalk, C++, C#, Eiffel and
Java) were created.
In these languages, data, and methods of
manipulating the data, are kept as a single
unit called an object.
The only way that a user can access the
data is via the object's "methods"
(subroutines).
Because of this, the internal workings of an
object may be changed without affecting
any code that uses the object.
[Independence]
Contd..
• May include features such as data
abstraction, encapsulation,
modularity, polymorphism, and
inheritance.
• Simula language in 1965, and
• Smalltalk in the 1970s, developed
• Many modern programming
languages now support OOP.
Contd..
There is still some controversy by
notable programmers such as
Alexander Stepanov, Richard Stallman
and others, concerning the efficacy of
the OOP paradigm versus the
procedural paradigm.
Polymorphism was developed as one
attempt to resolve this dilemma.
Since object-oriented programming
is considered a paradigm, not a
language, it is possible to create even
an object-oriented assembler language.
Contd…
Other Programming paradigms
that are often distinguished include
Machine paradigm
Processing paradigm
Declarative paradigm
Procedural paradigm
Knowledge Based paradigm and
Symbolic programming based
paradigm
Lowest Paradigm- Machine
Machine code
The lowest level programming
paradigms are machine code, which
directly represents the instructions
(the contents of program memory) as
a sequence of numbers, and
assembly language where the
machine instructions are represented
by mnemonics
These are sometimes called first- and
second-generation languages.
Contd..
In the 1960s, assembly languages
were developed to support library
COPY
Assembly was, and still is, used for
time critical systems and frequently
in embedded systems as it gives the
most direct control of what the
machine actually does.
Processing Paradigms
• A programming paradigm can be
understood as an abstraction of a
computer system, who is based on a
certain processing model or paradigm.

• Nowadays, the prevalent computer John von Nuemann


processing model used is the von
Neumann model, invented by John von
Neumann in 1945, influenced by Alan
Turing’s “Turing machine”.
• Data and program are residing in the memory.
• Control unit coordinates the components
sequentially following the program’s
instructions.
• Arithmetic Logical Unit performs the
calculations.
• Input/output provide interfaces to the exterior.

• The program and its data are what is


abstracted in a programming language Von Neumann Architecture
and translated into machine code by the
compiler/interpreter. 20
Procedural languages
Paradigm
The next advance was the development
of procedural languages. These
third-generation languages (the first
described as high-level languages) use
vocabulary related to the problem being
solved.
For example, COBOL (COmmon Business
Oriented Language) – uses terms like file,
move and copy.
FORTRAN (FORmula TRANslation) – using
mathematical language terminology, it
was developed mainly for scientific and
Contd..
 ALGOL (ALGOrithmic Language) – focused on
being an appropriate language to
define algorithms.
 PL/I (Programming Language One) – a hybrid
commercial/scientific general purpose
language supporting pointers.
 BASIC (Beginners All purpose Symbolic
Instruction Code) – it was developed to
enable more people to write programs.
C – a general-purpose programming
language, initially developed by Dennis
Ritchie between 1969 and 1973 at AT&T Bell
Labs.
Contd…
All these languages follow the
procedural paradigm.
That is, they describe, step by
step, exactly the procedure that
should, according to the particular
programmer at least, be followed to
solve a specific problem.
The efficacy and efficiency of any
such solution are both highly
dependent on that programmer's
experience, inventiveness and
Other Programming
Paradigms
Imperative Programming
( Procedural)
program as a collection of statements
and procedures affecting data
(variables)- Already discussed
Declarative Programming
•General programming paradigm in which programs
express the logic of a computation without
describing its control flow.

•Programs describe what the computation should


accomplish, rather than how it should accomplish it.

•Typically avoids the notion of variable holding state,


and function side-effects.

•Includes diverse languages/sub paradigms such as:


• Database query languages (e.g. SQL, Xquery)
• XSLT
• Makefiles
• Constraint programming
25
Some Languages by
Paradigm

Imperative (also called Structured


or Procedural) Programming
FORTRAN, BASIC, COBOL, Pascal, C
Object-Oriented Programming
SmallTalk, C++, Java
Functional Programming
LISP, ML, Haskell
History of Languages

1950s to 1960s
FORTRAN, COBOL, LISP, BASIC
1960s to 1970s
(ALGOL-based) Pascal and others
1970s to 1980s
Prolog, C, Ada
1980s to 1990s
C++, ML, Perl, Java
Knowledge-Based Programming...
Designed for the New generation of
programmers, the Wolfram Language
has a vast depth of built-in algorithms and
knowledge, all automatically accessible
through its elegant unified symbolic
language.
Scalable for programs from tiny to
huge, with immediate deployment
locally and in the cloud,
the Wolfram Language builds on clear
principles—and 25+ years of development
—to create what promises to be the world's
most productive programming language.
Knowledge-based programming: Wolfram releases
first demo of new language, 30 years in the making
End

You might also like