Imperative vs Declarative programming paradigm

Home / Blogs / Imperative vs Declarative programming paradigm

This is a series of blogs where I collect some interesting programming concepts, new things I learn

As LabVIEWers we’re familiar with few programming paradigms like object-oriented (OOP). Have you heard of functional programming?

Imperative Programming changes the state of the program. OOP is an imperative programming

Declarative Programming: doesn’t change the state of the program. Functional is a declarative programming

Wikipedia has more details on the programming paradigm

2 main principles of Functional Programming

  1. Don’t mutate. Don’t change the state of the program, whatever data comes into the function make a new copy of the function and return the new data without modifying the original data.
  2. Keep the function purely independent ie., even if you want to play with the global variables, then pass that global variable as arguments to that function .. this keeps the function purely independent and the results from the fund will be repeatable at all time. This is good for testing too.

In general we do the mix & match of both in a all kind of the programming language, at least in the application layers though not in the library layers. I imagine libraries would be clean only when it’s functional in nature.

I think the reason for most modern browsers consuming lot of memory is that these paradigms followed in the modern websites, which keeps generating the new copy of the existing data. Is that so? What’s your opinion?

Leave a Reply

Your email address will not be published. Required fields are marked *