re: Explain Declarative vs Imperative Programming like I'm 5 VIEW POST

re: The typical answer you'll get is "declarative programming is what, imperative programming is how". I'll expand on that a little bit: "declarative p...

This is an interesting read and exhaustive. Thanks for sharing

When using a framework (like Vue), it is able to take care of a lot of things behind the scenes that you would otherwise need to do by hand, for example updating the UI when the list variable changes (and it's able to help make sure that it's generally performant with less thought from the developer).

I'm not sure how to understand this part. Does a framework cutting down on what I need to write in a way making me write "declarative programming" i.e "declarative programming means describing what the end result should be"? Because in the example of the UI between vue and jquery, the Vue abstracts the rendering of the template away, whereas the Jquery approach, one has to write it out.

In other words, behinds the scenes, the Vue abstraction that got the rendering of the li to happen would have be declarative or imperative?

Maybe I'm confused.


If I'm understanding your question correctly, yes, Vue's internals use imperative code so that consumers of the tool are able to stick to declarative code. This is much like a database engine - the operations required to execute your SQL query are calculated by the database engine and invisible to the user, but will naturally be implemented inside the engine in an imperative fashion. Somewhere in the pipeline you will always need to imperatively tell the computer what to do.

Code of Conduct Report abuse