Declarative and Imperative paradigms

Hi! welcome to my blog. let's see what the declarative and imperative paradigms in programming paradigms are. Before moving into comparison lets get to know what a programming paradigm is.
A programming paradigm simply means "the way of programming". There are several common paradigms and classification based on their features and characteristics. The main two programming paradigms are Functional programming and Object-Oriented Programming. Now let's focus on declarative and imperative paradigms.
Declarative paradigm is when you programming by determining the outcome you need, not how to get it. it expresses the logic of a computation without describing its control flow.
Imperative paradigm is programming with an explicit sequence of commands that update state.

Programming languages tend to have multi-paradigm tendencies using both imperative and declarative syntax - Martin Novák




Example of Imperative programme

var num = [1,2,3];
var doubleNum = [];
for (var i = 0; i<num.length;i++)
{
    doubleNum.push (num[i]*2);
}


Example of Declarative programme

var num = [1,2,3];
vr doubleNum = num.map(function(num)
{
   return num*2;
});

hope you understood what is Declarative and Imperative paradigms and what are the differences between Declarative and Imperative paradigms are. for more info check out this video  Sam Nxstack

Thank you




















Comments

Popular Posts