Programming Paradigms

What is Programming Paradigm

Paradigm can also be termed as method to solve some problem or do some task.

Programming paradigm is an approach to solve problem using some programming language or also we can say it is a method to solve a problem using tools and techniques that are available to us following some approach. There are lots for programming language that are known but all of them need to follow some strategy when they are implemented and this methodology/strategy is paradigms. Apart from varieties of programming language there are lots of paradigms to fulfil each and every demand.

Declarative Programming

Declarative programming is a contrast programming paradigm. In computer science, declarative programming is a programming paradigm—a style of building the structure and elements of computer programs—that expresses the logic of a computation without describing its control flow.

This paradigm emphasizes the concept of what to do rather than how to do it. Declarative programming is like when you ask your friend to write an essay, you don’t care how does he write it, you just want to get the result.

Now we look back to the real-world example as we mentioned earlier in the Imperative programming section:

Example: I’m in the park which nearby your house but I still cannot find a way to get your house. How do I get your house from here?

Response: 7830 Pineknoll Road, Sykesville, MD 21784

So, by this declarative response, I don’t care how does he get to my house’s location, I just give him the address then wait for him coming for me (the result).

Functional programming is a form of declarative programming, in which the desired result is declared as the value of a series of function applications. People often use those terms interchangeably. The outstanding example of a functional programming language is Haskell. If you want to learn more about functional programming or declarative programming, you should consider reading this article that gives you a reason to learn Haskell and also learning resources. Underneath, I also introduce some concepts and code examples in the Haskell programming language.

In JavaScript, besides supporting imperative programming, you can also write declarative (functional) programming at the same time by using some of those function mapreducefilter.

Now we listed 4 examples in imperative programming section again and see what we will do to make those declarative:

One Reply to “Programming Paradigms”

Comments are closed.