You are on page 1of 7

GOOD MORNING, EVERYONE!

WE’RE THE GROUP 1 AND FOR TODAY'S


DISCUSSION, WE'LL BE TALKING ABOUT PROGRAMMING PARADIGMS.

SO, WHAT IS PROGRAMMING PARADIGM?

PROGRAMMING PARADIGM IS a way of programming it is a CLASSIFICATION or


STYLE ng pagpoPROGRAM. it is an approach to solve problems by using
programming languages.

Gumagamit tayo ng programming paradigm para maintindihan natin kung paano


isosolve yung isang problem and pano tayo makakapag come up ng solution.

IT DEFINES A PROGRAMMING LANGUAGE AND HOW IT WORKS

Aware naman tayo sa mga programming languages, and that each programming
languages ay may different approach, they all come under the two primary
paradigms, imperative and declarative, which will be discussed in more detail
later.

So bakit nga ba may iba’t ibang programming paradigm?

Programming paradigms kasi comes in a variety of forms, diba sobrang dami and
because each one is unique, importante na makapili tayo ng pinaka suitable and
appropriate na paradigm. May mga paradigm kasi na yung approach nila is di
naman magdudulot ng maganda sa code mo so parang useless lang siya kasi di
naman na solve yung problem.

Kaya mas maganda na mag explore tayo ng different paradigms for us to know
and to understand kung anong paradigm yung mas better and makakatulong
satin sa pagcocode.

Imperative vs. declarative

Eto yung two main programming paradigm na nasabi ko kanina.

Yung imperative programming nagfofocus siya sa mga sequential set of


commands. In sequence yung command para siyang step by step. Kung pano
gawin to ganyan kaya may how, nagfofocus siya sa how, kung pano maaachieve
yung certain goal.

Yung declarative programming naman is nagfofocus sa logic and concepts, for


example yung logic ng computation yung logic lang kung pano I compute pero di
na natin idedescribe yung flow kung pano niya kukunin. “What” needs to be
done sa declarative hindi siya kung pano to gagawin. Mas focus siya result rather
than how to get it.
For example diba sa sql pag may gusto tayo makita na record itatype lang natin
don na SELECT * FROM <kung anong TableName> ganyan di naman natin nilalagay
kung pano niya dapat gawin or kunin ng step by step, need lang natin yung result.

EXAMPLE

 Imperative Programming is like your friend calling your father that tells her how
to fix your car step by step.
 Declarative Programming is like asking your friend to fix your car. You don’t
care how to fix it, that’s up to her.

A great C# example of declarative vs. imperative programming is LINQ.

With imperative programming, you tell the compiler what you want to happen, step by step.

For example, let's start with this collection, and choose the odd numbers:

List<int> collection = new List<int> { 1, 2, 3, 4, 5 };


With imperative programming, we'd step through this, and decide what we want:

List<int> results = new List<int>();


foreach(var num in collection)
{
if (num % 2 != 0)
results.Add(num);
}
Here, we're saying:

1. Create a result collection


2. Step through each number in the collection
3. Check the number, if it's odd, add it to the results
With declarative programming, on the other hand, you write code that describes what you
want, but not necessarily how to get it (declare your desired results, but not the step-by-
step):

var results = collection.Where( num => num % 2 != 0);


Here, we're saying "Give us everything where it's odd", not "Step through the collection.
Check this item, if it's odd, add it to a result collection."

REFERENCE:

https://www.indicative.com/resource/programming-paradigm/
https://towardsdatascience.com/what-is-a-programming-paradigm-1259362673c2
https://stackoverflow.com/questions/1784664/what-is-the-difference-between-declarative-
and-imperative-paradigm-in-programmin
https://www.ionos.com/digitalguide/websites/web-development/declarative-programming/
imperative in which the programmer instructs the machine how to change its state,

 declarative in which the programmer merely declares properties of the


desired result, but not how to compute it
 Declarative programming is a programming paradigm … that expresses the
logic of a computation without describing its control flow.
Imperative programming is a programming paradigm that uses statements that
change a program’s state.
 Declarative Programming is like asking your friend to fix your car. You don’t
care how to fix it, that’s up to her.
 Imperative Programming is like your friend calling your father that tells her how
to fix your car step by step.

Programming Paradigm Defined

A programming paradigm is the classification, style or way of programming. It is an


approach to solve problems by using programming languages. Depending on the
language, the difficulty of using a paradigm differs.

A programming paradigm is the concept by which the methodology of a programming


language adheres to. Paradigms are important because they define a programming
language and how it works. A great way to think about a paradigm is as a set of ideas that
a programming language can use to perform tasks in terms of machine-code at a much
higher level. These different approaches can be better in some cases, and worse in others.
A great rule of thumb when exploring paradigms is to understand what they are good at.
While it is true that most modern programming languages are general-purpose and can
do just about anything, it might be more difficult to develop a game, for example, in a
functional language than an object-oriented language.

If you mean why do we need more then ONE paradigm, its because of a few things ...
(1) Different paradigms are better or worse suited to different problems.
(2) Paradigms evolve and grow, generally becoming more capable in the process.

Each paradigm consists of certain structures, features, and opinions about how common
programming problems should be tackled.

The question of why are there many different programming paradigms is similar to why
are there many programming languages. Certain paradigms are better suited for certain
types of problems, so it makes sense to use different paradigms for different kinds of
projects.

Programming paradigms are not languages or tools. You can't "build" anything with a
paradigm. They're more like a set of ideals and guidelines that many people have agreed
on, followed, and expanded upon.

Paradigms are important because they define a programming language and how it works.
A great way to think about a paradigm is as a set of ideas that a programming language
can use to perform tasks in terms of machine-code at a much higher level. These different
approaches can be better in some cases, and worse in others.

Can a programming language support more than one paradigm?


YES
Most programming languages support more than one programming paradigm to
allow programmers to use the most suitable programming style and associated
language constructs for a given job.

Can you mix programming paradigms?


YES
Mixing paradigms is fine as long as it doesn't have a negative impact on quality of
your code.

 imperative in which the programmer instructs the machine how to change its
state,
o procedural which groups instructions into procedures,
o object-oriented which groups instructions with the part of the state
they operate on,
 declarative in which the programmer merely declares properties of the
desired result, but not how to compute it
o functional in which the desired result is declared as the value of a
series of function applications,
o logic in which the desired result is declared as the answer to a
question about a system of facts and rules,
o mathematical in which the desired result is declared as the solution
of an optimization problem
o reactive in which the desired result is declared with data streams
and the propagation of change

Declarative programming is a programming paradigm … that expresses the logic of a


computation without describing its control flow.
Imperative programming is a programming paradigm that uses statements that
change a program’s state.
Declarative Programming is like asking your friend to fix your car. You don’t care how
to fix it, that’s up to her.
Imperative Programming is like your friend calling your father that tells her how to fix
your car step by step.

 Declarative - specify what to do, not how to do it


 E.g.: HTML describes what should appear on a web page, not how it
should be drawn on the screen
 Imperative - specify both what and how
 int x; - what (declarative)
 x=x+1; - how

You might also like