0% found this document useful (0 votes)
9 views17 pages

2 Programming Paradigm 1

The document discusses programming paradigms, categorizing them into two main branches: imperative and declarative. It details sub-paradigms such as procedural, object-oriented, functional, and logic programming, along with their advantages and examples. Additionally, it mentions multi-paradigm languages that support various programming approaches, highlighting the flexibility of modern languages like Python.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views17 pages

2 Programming Paradigm 1

The document discusses programming paradigms, categorizing them into two main branches: imperative and declarative. It details sub-paradigms such as procedural, object-oriented, functional, and logic programming, along with their advantages and examples. Additionally, it mentions multi-paradigm languages that support various programming approaches, highlighting the flexibility of modern languages like Python.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Programming Languages

CS 321
PROGRAMMING
PARADIGMS
WHAT IS PROGRAMMING PARADIGM?

•Programming paradigms are fundamental


conceptual frameworks that determine how
computational problems are formulated and
solved.
PROGRAMMING PARADIGM
IMPERATIVE DECLARATIVE
PROGRAMMING PROGRAMMING

PROCEDURAL PROGRAMMING LOGIC PROGRAMMING

OBJECT ORIENTED PROGRAMMING FUNCTIONAL PROGRAMMING


2 Main Branches
1. Imperative: Focuses on how to achieve a
result through a sequence of instructions that
changes the program state.
2. Declarative: Focuses on what the desired
results is, often using logic or mathematical
functions without explicitly describing the
control flow.
IMPERATIVE PROGRAMMING PARADIGM
• Idea: The computer follows a step-by-step
commands.

Sub-Paradigms:
• Procedural: Organizes code into procedures or
functions (e.g., C).
• Object-Oriented (OOP): Organizes code around
"objects" that contain data and methods
IMPERATIVE PROGRAMMING PARADIGM
ADVANTAGES: DISADVANTAGES:

1. Very simple to 1. Complex problem cannot


implement. be solve.
2. It contains loops, 2. Less efficient and less
variables etc. productive.
3. Parallel programming is
not possible.
PROCEDURAL PROGRAMMING PARADIGM

•Focuses on a step-by-step sequence of


instructions or "procedures" (functions) to
perform a task.
•The program is viewed as a series of
computational steps. It relies heavily on
local and global variables to manage state.
Examples of Procedural programming
paradigm:
• C : developed by Dennis Ritchie and Ken
Thompson
• C++ : developed by Bjarne Stroustrup
• Java : developed by James Gosling at Sun
Microsystems
• ColdFusion : developed by J J Allaire
• Pascal : developed by Niklaus Wirth
OBJECT ORIENTED PROGRAMMING
• Concept: Modeling the Real World
• Instead of focusing on logic, it focuses on objects—units that
combine data (attributes) and behavior (methods).

The Four Pillars:


1. Encapsulation: Hiding internal state.
2. Abstraction: Simplifying complex reality.
3. Inheritance: Reusing code via parent/child relationships.
4. Polymorphism: Using a single interface for different data
types.
Object Oriented Programming
ADVANTAGES:

1. Data Security
2. Inheritance
3. Code reusability
4. Flexible and abstraction is also present
Examples of Object Oriented
Programming paradigm:
• Simula : first OOP language
• Java : developed by James Gosling at Sun Microsystems
• C++ : developed by Bjarne Stroustrup
• Objective-C : designed by Brad Cox
• Visual Basic .NET : developed by Microsoft
• Python : developed by Guido van Rossum
• Ruby : developed by Yukihiro Matsumoto
• Smalltalk : developed by Alan Kay, Dan Ingalls, Adele
Goldberg
DECLARATIVE PROGRAMMING PARADIGM
Idea: Expresses the logic of a computation
without describing its control flow.

Sub-Paradigms:
•Functional: Treats computation as the
evaluation of mathematical functions and avoids
changing-state and mutable data.
•Logic-Based: Based on formal logic; the program
is a set of facts and rules.
FUNCTIONAL PROGRAMMING PARADIGM

•Treats computation as the evaluation of


mathematical functions.
•Immutability: Once a variable is set, it
cannot be changed. This eliminates "side
effects," making code highly predictable
and easier to test.
LOGIC PROGRAMMING PARADIGM

•Programming is treated as a set of formal


logic statements.
•Knowledge Base: You define a set of Facts
and Rules.
•The computer uses an inference engine to
answer queries based on the provided logic
MULTI-PARADIGM

• A multi-paradigm programming languages is a


programming language that supports more than
one approach to programming.
• Most modern languages like Python are multi-
paradigm. They support Object-Oriented
programming in combination with imperative
and procedural styles.
Thank you.

You might also like