loading...

What is Declarative vs Imperative

dechamp profile image DeChamp ・1 min read

So this is one that even to this day, I have to google every now and then. I'm making an effort to write a post from now on, any time I have to research something. The hope is it'll help me remember and also that it will help someone else in the same boat!

So here it goes.

I just watched a great video on it that does a great job to explain the difference. You can find it here.

Chris Boesch says in the video, that it's simplest form is as follows.

  • Imperative: How to do something
  • Declarative: What to do

The example Chris gives further is that of when you get in a Taxi.

Imperative would be if you gave the Taxi driver a step by step instruction of how to get where you are going.

Declarative is like saying "take me to the white house"

If you want a code example, definitely watch the video linked above.

One last way to remember, borrowed from zsoc on IRC ##javascript, he stated declarative... as in 'declaring' something.. like "I'm going to do this thing" vs "this is how im going to do something"

anywho, hope that helps some of ya.

--DeChamp

Posted on by:

dechamp profile

DeChamp

@dechamp

Just a coder and a dad. I love my family and I love to code!!!! started coding at 11, so I have 25 years under my belt. Still love learning about it every day. Follow me on instagram @codeFiend

Discussion

pic
Editor guide