Loredra L
Loredra L

Reputation: 1553

Is behind the hood of declarative coding is still imperative in Javascript?

I read the difference of imperative and declarative paradigms here

https://codeburst.io/declarative-vs-imperative-programming-a8a7c93d9ad2

The author then use React and JQuery as examples, but then under all the cool stuffs that React use, it must have been normal Javascript which must be imperative,isnt it? (Do this then do that, etc. ...)

There are languages that said to be declarative by nature (SQL), am I correct to say that Javascript is imperative by nature, but can be declarative then?

Upvotes: 1

Views: 332

Answers (1)

DysphoricUnicorn
DysphoricUnicorn

Reputation: 552

I can only really speak about jQuery here since I never worked with React before.

jQuery is written in JavaScript and as such is imperative "under the hood". It simply gives you the option to write more or less declarative code by having a bunch of predefined functions. If you think about it this way, pretty much everything is imperative "under the hood" though because, once compiled, everything is broken into simple imperative instructions.

In most cases the technology behind what you are using will not matter to you. So while you are using a declarative framework on top of a imperative language, you are still writing declarative code.

Upvotes: 2

Related Questions