4 ms·
Just to be sure, what do you mean by executing node declarations? Seems then to me that it is exactly the example of declaring variables. The order doesn't mat
by aatd86 4y ago
Just to be sure, what do you mean by executing node declarations?
Seems then to me that it is exactly the example of declaring variables.
The order doesn't matter indeed.
But for operations on these variables, i.e. function calls, there needs to be an ordering between variable declarations and functions calls (source order) except in a few cases maybe where a language uses hoisting.
That's in the simple case where there are no side effects (but the parent comment takes this into account already).
Of course, when someone transforms an html element into its corresponding DOM node, because this does not depend on shared state, these operations can be commuted but that's not what declarativity is about.
Declarative is: cook me a chicken.
As opposed to imperative i.e.: turn the oven on, wash and season the chicken, put it on the oven, wait 1hour, get if off the oven and serve it.
You can buy the chicken or the oven whichever first. Still need to follow the steps in order.
I'm still not quite sure I understand what you meant exactly :/
- galaxyLogic 4y agoI'm still a bit confused about the distinction. A HTML-page would be a declarative definition of a DOM-structure, right? It just declares what I want to see in the browser, it does not describe how the browser-engine shall render the HTML given to show it to my readers. Good so far, declarative. But what if the web-page shows a cookbook recipe whose steps are elements in the DOM-structure of the page? Such a page then procedurally describes how to cook a cake, right? Is that recipe then declarative or procedural?
- aatd86 4y agoThe html code is a declarative definition of a webpage. The internal representation as a DOM tree is just the imperative implementation on the backend. A recipe is a description of the steps to the end result. So it's imperative. Here instead of DOM nodes, you probably have utensils and ingredients on which you apply operations (grab, heat, pour oil etc...) The end goal is not the description of the recipe itself. It's the meal that you get once you have followed the steps to completion.
- galaxyLogic 4y agoBut my end-goal could be finding the recipe, maybe I am a recipe collector.