Take A Closer Look at The Programming Paradigms
Take A Closer Look at The Programming Paradigms
at the Programming
Paradigms
Software/Data Engineer
because I will be dealing with
both software development and
data pipeline development
If you ever have something to ask me, feel free to do so!
You may also connect or follow me on social media~
activeness
wisn#6051
wisn98
wisn
randomness
wisn98
Alright!
Now back to the topic!
So, yes, programming…
So, yes, programming…
but
How?
Some might answer why not?
Well, I believe we program a computer because we need
it to help us to solve a (computational) problem.
int main() {
int a = 1;
int b = 2;
printf("%d\n", a + b);
return 0;
}
Now, what is a programming language?
syntax
int main() {
int a = 1;
int b = 2;
printf("%d\n", a + b);
return 0;
}
Now, what is a programming language?
syntax
int main() {
int a = 1;
int b = 2;
Is this valid?
printf("%d\n", a + b);
return 0;
}
Now, what is a programming language?
syntax
int main() {
int a = 1;
int b = 2;
Is this valid?
printf("%d\n", a + b);
return 0;
}
Now, what is a programming language?
syntax
int main() {
int a = 1;
int b = 2;
Is this valid? Check the grammar rules!
printf("%d\n", a + b);
return 0;
}
Now, what is a programming language?
syntax
int main() {
int a = 1;
int b = 2;
Is this valid? Check the grammar rules!
printf("%d\n", a + b);
C++ assignment grammar actually pretty
return 0;
complex so I will oversimplify it.
}
Now, what is a programming language?
syntax
int main() {
int a = 1;
int b = 2;
Is this valid? Check the grammar rules!
printf("%d\n", a + b);
C++ assignment grammar actually pretty
return 0;
complex so I will oversimplify it.
}
assignment := data-type whitespace
name whitespace
‘=’ whitespace
expression whitespace ‘;’
Now, what is a programming language?
syntax
int main() {
int a = 1;
int b = 2;
Is this valid? Check the grammar rules!
printf("%d\n", a + b);
C++ assignment grammar actually pretty
return 0;
complex so I will oversimplify it.
}
assignment := data-type whitespace
name whitespace
‘=’ whitespace
expression whitespace ‘;’
Now, what is a programming language?
syntax
int main() {
int a = 1;
int b = 2;
Is this valid? Check the grammar rules!
printf("%d\n", a + b);
C++ assignment grammar actually pretty
return 0;
complex so I will oversimplify it.
}
assignment := data-type whitespace
name whitespace
‘=’ whitespace
expression whitespace ‘;’
Now, what is a programming language?
syntax
int main() {
int a = 1;
int b = 2;
Is this valid? Check the grammar rules!
printf("%d\n", a + b);
C++ assignment grammar actually pretty
return 0;
complex so I will oversimplify it.
}
assignment := data-type whitespace
name whitespace
‘=’ whitespace
expression whitespace ‘;’
Now, what is a programming language?
syntax
int main() {
int a = 1;
int b = 2;
Is this valid? Check the grammar rules!
printf("%d\n", a + b);
C++ assignment grammar actually pretty
return 0;
complex so I will oversimplify it.
}
assignment := data-type whitespace
name whitespace
‘=’ whitespace
expression whitespace ‘;’
Now, what is a programming language?
syntax
int main() {
int a = 1;
int b = 2;
Is this valid? Check the grammar rules!
printf("%d\n", a + b);
C++ assignment grammar actually pretty
return 0;
complex so I will oversimplify it.
}
assignment := data-type whitespace
name whitespace
‘=’ whitespace
expression whitespace ‘;’
valid!
Now, what is a programming language?
semantic
int main() {
int a = 1;
int b = 2;
printf("%d\n", a + b);
return 0;
}
Now, what is a programming language?
semantic
int main() {
int a = 1;
int b = 2;
printf("%d\n", a + b);
What is the meaning of this?
return 0; How do we evaluate this?
} What is the order of the execution?
Now, what is a programming language?
printf("%d\n", a + b);
What is the meaning of this?
return 0; How do we evaluate this?
} What is the order of the execution?
Now, what is a programming language?
printf("%d\n", a + b);
What is the meaning of this?
return 0; How do we evaluate this?
} What is the order of the execution?
printf("%d\n", a + b);
What is the meaning of this?
return 0; How do we evaluate this?
} What is the order of the execution?
To be honest, I’m not really sure. I can’t find a clear answer so far.
What is the difference between an execution model and a model of computation?
To be honest, I’m not really sure. I can’t find a clear answer so far.
To be honest, I’m not really sure. I can’t find a clear answer so far.
To be honest, I’m not really sure. I can’t find a clear answer so far.
We focus on this instead. This is basically where we model our solution through programming.
Also, this is related to our main topic which is programming paradigm.
Maybe this is how we see it.
execution model
model of computation
Model of computations are classified into three categories.
Model of computations are classified into three categories.
Sequential Model
Model of computations are classified into three categories.
Imperative Programming
● Procedural programming
● Object-oriented programming
● and so on (if any)
Model of computations are classified into three categories.
Imperative Programming
● Procedural programming
● Object-oriented programming
● and so on (if any)
Model of computations are classified into three categories.
Declarative Programming
Imperative Programming
● Functional programming
● Procedural programming
● Logic programming
● Object-oriented programming
● Constraint programming
● and so on (if any)
● Query language
● and so on
Model of computations are classified into three categories.
Declarative Programming
Imperative Programming
● Functional programming
● Procedural programming
● Logic programming
● Object-oriented programming
● Constraint programming
● and so on (if any)
● Query language
● and so on
Model of computations are classified into three categories.
Declarative Programming
Imperative Programming Concurrent Programming
● Functional programming
● Procedural programming ● Actor-based programming
● Logic programming
● Object-oriented programming ● Choreographic programming
● Constraint programming
● and so on (if any) ● and so on
● Query language
● and so on
Model of computations are classified into three categories.
Declarative Programming
Imperative Programming Concurrent Programming
● Functional programming
● Procedural programming ● Actor-based programming
● Logic programming
● Object-oriented programming ● Choreographic programming
● Constraint programming
● and so on (if any) ● and so on
● Query language
● and so on
Imperative programming? What is that?
Imperative programming? What is that?
...
int i = 0;
int n = list.size();
while (i < n) {
// take something
// compute something
// put something
}
...
Imperative programming? What is that?
...
int i = 0;
int n = list.size();
while (i < n) {
// take something flow
// compute something
// put something
}
...
Imperative programming? What is that?
...
int i = 0;
int n = list.size();
while (i < n) {
// take something flow
// compute something
// put something
}
...
control flow
Imperative programming? What is that?
... state
int i = 0;
int n = list.size();
while (i < n) {
// take something flow
// compute something
// put something
}
...
control flow
Imperative programming? What is that?
... state
int i = 0;
int n = list.size();
while (i < n) {
// take something flow
// compute something
// put something
}
change the state
...
i += 1
control flow
Imperative programming? What is that?
Both procedural programming and object-oriented programming are derived from imperative programming.
What is the difference between the two?
Imperative programming? What is that?
Both procedural programming and object-oriented programming are derived from imperative programming.
What is the difference between the two?
Procedural Object-oriented
Procedure Method
Record Object
Module Class
Imperative
...
int n, target;
cin >> n >> target;
...
How do we see imperative, procedural, and object-oriented?
Imperative Procedural
... ...
...
How do we see imperative, procedural, and object-oriented?
Imperative Procedural
... ...
...
How do we see imperative, procedural, and object-oriented?
Imperative Procedural
... ...
...
How do we see imperative, procedural, and object-oriented?
Imperative Procedural
... ...
...
How do we see imperative, procedural, and object-oriented?
Imperative Object-oriented
... ...
Imperative Object-oriented
... ...
Imperative Object-oriented
... ...
Procedural Object-oriented
... ...
Procedural Object-oriented
... ...
Procedural Object-oriented
... ...
It focuses on what to execute, defines program logic, but not detailed control flow.
Declarative programming? What is that?
It focuses on what to execute, defines program logic, but not detailed control flow.
SELECT book_id, book_name FROM books WHERE book_name ILIKE ‘pro%’ ORDER BY book_id ASC LIMIT
10;
Declarative programming? What is that?
It focuses on what to execute, defines program logic, but not detailed control flow.
SELECT book_id, book_name FROM books WHERE book_name ILIKE ‘pro%’ ORDER BY book_id ASC LIMIT
10;
It focuses on what to execute, defines program logic, but not detailed control flow.
SELECT book_id, book_name FROM books WHERE book_name ILIKE ‘pro%’ ORDER BY book_id ASC LIMIT
10;
It focuses on what to execute, defines program logic, but not detailed control flow.
SELECT book_id, book_name FROM books WHERE book_name ILIKE ‘pro%’ ORDER BY book_id ASC LIMIT
10;
It focuses on what to execute, defines program logic, but not detailed control flow.
SELECT book_id, book_name FROM books WHERE book_name ILIKE ‘pro%’ ORDER BY book_id ASC LIMIT
10;
It focuses on what to execute, defines program logic, but not detailed control flow.
SELECT book_id, book_name FROM books WHERE book_name ILIKE ‘pro%’ ORDER BY book_id ASC LIMIT
10;
However, what I know is that if I run this query then I will get a list of book (its id and name) with
“pro” as the starting name and the number of the book is 10.
Declarative programming? What is that?
It focuses on what to execute, defines program logic, but not detailed control flow.
SELECT book_id, book_name FROM books WHERE book_name ILIKE ‘pro%’ ORDER BY book_id ASC LIMIT
10;
However, what I know is that if I run this query then I will get a list of book (its id and name) with
“pro” as the starting name and the number of the book is 10.
It focuses on what to execute, defines program logic, but not detailed control flow.
SELECT book_id, book_name FROM books WHERE book_name ILIKE ‘pro%’ ORDER BY book_id ASC LIMIT
10;
However, what I know is that if I run this query then I will get a list of book (its id and name) with
“pro” as the starting name and the number of the book is 10.
Now, both functional programming and logic programming are classified as declarative programming.
What’s the difference though?
Declarative programming? What is that?
Now, both functional programming and logic programming are classified as declarative programming.
What’s the difference though?
Functional
...
main :: IO ()
main = (print . uncurry gcd' . listToTuple . convertToInt . words) =<< input
...
Declarative programming? What is that?
Now, both functional programming and logic programming are classified as declarative programming.
What’s the difference though?
Functional
...
Basically, everything is a function.
main :: IO () We compose many functions to get a result.
main = (print . uncurry gcd' . listToTuple . convertToInt . words) =<< input
...
Declarative programming? What is that?
Now, both functional programming and logic programming are classified as declarative programming.
What’s the difference though?
Functional
...
Basically, everything is a function.
main :: IO () We compose many functions to get a result.
main = (print . uncurry gcd' . listToTuple . convertToInt . words) =<< input
How about the execution order?
gcd' :: Integral a => a -> a -> a
gcd' n 0 = n
gcd' n m = gcd' m (n `mod` m)
...
Declarative programming? What is that?
Now, both functional programming and logic programming are classified as declarative programming.
What’s the difference though?
Functional
...
Basically, everything is a function.
main :: IO () We compose many functions to get a result.
main = (print . uncurry gcd' . listToTuple . convertToInt . words) =<< input
How about the execution order?
gcd' :: Integral a => a -> a -> a
gcd' n 0 = n Depends on the order of the function!
gcd' n m = gcd' m (n `mod` m)
...
Declarative programming? What is that?
Now, both functional programming and logic programming are classified as declarative programming.
What’s the difference though?
Functional
...
Basically, everything is a function.
main :: IO () We compose many functions to get a result.
main = (print . uncurry gcd' . listToTuple . convertToInt . words) =<< input
How about the execution order?
gcd' :: Integral a => a -> a -> a
gcd' n 0 = n Depends on the order of the function!
gcd' n m = gcd' m (n `mod` m)
...
Declarative programming? What is that?
Now, both functional programming and logic programming are classified as declarative programming.
What’s the difference though?
Functional
...
Basically, everything is a function.
main :: IO () We compose many functions to get a result.
main = (print . uncurry gcd' . listToTuple . convertToInt . words) =<< input
How about the execution order?
gcd' :: Integral a => a -> a -> a
gcd' n 0 = n Depends on the order of the function!
gcd' n m = gcd' m (n `mod` m)
...
Declarative programming? What is that?
Now, both functional programming and logic programming are classified as declarative programming.
What’s the difference though?
Functional
1
...
Basically, everything is a function.
main :: IO () We compose many functions to get a result.
main = (print . uncurry gcd' . listToTuple . convertToInt . words) =<< input
How about the execution order?
gcd' :: Integral a => a -> a -> a
gcd' n 0 = n Depends on the order of the function!
gcd' n m = gcd' m (n `mod` m)
...
Declarative programming? What is that?
Now, both functional programming and logic programming are classified as declarative programming.
What’s the difference though?
Functional
... 2 Basically, everything is a function.
main :: IO () We compose many functions to get a result.
main = (print . uncurry gcd' . listToTuple . convertToInt . words) =<< input
How about the execution order?
gcd' :: Integral a => a -> a -> a
gcd' n 0 = n Depends on the order of the function!
gcd' n m = gcd' m (n `mod` m)
...
Declarative programming? What is that?
Now, both functional programming and logic programming are classified as declarative programming.
What’s the difference though?
Functional
...
3 Basically, everything is a function.
main :: IO () We compose many functions to get a result.
main = (print . uncurry gcd' . listToTuple . convertToInt . words) =<< input
How about the execution order?
gcd' :: Integral a => a -> a -> a
gcd' n 0 = n Depends on the order of the function!
gcd' n m = gcd' m (n `mod` m)
...
Declarative programming? What is that?
Now, both functional programming and logic programming are classified as declarative programming.
What’s the difference though?
Functional
...
and so on Basically, everything is a function.
main :: IO () We compose many functions to get a result.
main = (print . uncurry gcd' . listToTuple . convertToInt . words) =<< input
How about the execution order?
gcd' :: Integral a => a -> a -> a
gcd' n 0 = n Depends on the order of the function!
gcd' n m = gcd' m (n `mod` m)
...
Declarative programming? What is that?
Now, both functional programming and logic programming are classified as declarative programming.
What’s the difference though?
Logic
monotone([]) :- !.
monotone([_, _|[]]) :- !.
monotone([X, Y|T]) :- X =< Y, monotone_increasing([X, Y|T]), !.
monotone([X, Y|T]) :- monotone_decreasing([X, Y|T]).
monotone_increasing([]).
monotone_increasing([H|T]) :- monotone_increasing_helper(H, T), monotone_increasing(T).
monotone_increasing_helper(_, []).
monotone_increasing_helper(X, [H|T]) :- X =< H, monotone_increasing_helper(X, T).
monotone_decreasing([]) :- !.
monotone_decreasing([H|T]) :- monotone_decreasing_helper(H, T), monotone_decreasing(T).
monotone_decreasing_helper(_, []) :- !.
monotone_decreasing_helper(X, [H|T]) :- X >= H, monotone_decreasing_helper(X, T).
Declarative programming? What is that?
Now, both functional programming and logic programming are classified as declarative programming.
What’s the difference though?
Now, both functional programming and logic programming are classified as declarative programming.
What’s the difference though?
Now, both functional programming and logic programming are classified as declarative programming.
What’s the difference though?
That is we know the characteristic and the strength of each programming paradigm.
Making it easy for us to choose the right toolbox to solve a certain problem.
After all, programming paradigm is something that we use to model a solution.
Why should we learn these different programming paradigms?
That is we know the characteristic and the strength of each programming paradigm.
Making it easy for us to choose the right toolbox to solve a certain problem.
After all, programming paradigm is something that we use to model a solution.
Like, some problems are easier to solve with step-by-step approach of the imperative programming.
However, some problems are actually easier to solve by composing many functions.
Or maybe, there are problems in which are easier to solve by combining facts.
Fin!
QnA session now, baby!
If there is something that need to be corrected, please feel free to correct me!
Do contact me and explain.
After all, just like you guys, I’m also still in the middle of learning things!