… a style of building the structure and elements of computer programs—that expresses the logic of a computation without describing its control flow.
Given that definition SQL seems like a good example of declarative programming. A statement expressed in Data Manipulation Language "declares" the nature of the data desired while the manner in which it is obtained is left entirely up to the RDBMS engine.
Now based on that example writing components containing imperative code to generate SQL statements (DML) is not declarative programming.
Declarative - React makes it painless to create interactive UIs. Design simple views for each state in your application, and React will efficiently update and render just the right components when your data changes.
So "declarative approach to building UIs" is double speak for "I can't be bothered dealing closely with the actual DOM - ever."
as you mentioned a better way is to optimize code at build time and React team is aware of that
However the freedom to do something like this is why we prefer to have control over scheduling, and why setState() is asynchronous. Conceptually, we think of it as “scheduling an update”.
The control over scheduling would be harder for us to gain if we let the user directly compose views with a “push” based paradigm common in some variations of Functional Reactive Programming. We want to own the “glue” code.
i.e. the design philosophy prefers run time control over compile time commitment.
Declarative - React makes it painless to create interactive UIs. Design simple views for each state in your application, and React will efficiently update and render just the right components when your data changes.
So "declarative approach to building UIs" is double speak for "I can't be bothered dealing closely with the actual DOM - ever."
But you can have stateful function components with hooks and using hooks makes a component impure, right? Technically yes, but in practice not really as I touched upon here.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
animal-dynamics.com/ad-blog/the-bu... 😛
The original statement:
… an excerpt from Wikipedia
Given that definition SQL seems like a good example of declarative programming. A statement expressed in Data Manipulation Language "declares" the nature of the data desired while the manner in which it is obtained is left entirely up to the RDBMS engine.
Now based on that example writing components containing imperative code to generate SQL statements (DML) is not declarative programming.
From the React landing page:
So "declarative approach to building UIs" is double speak for "I can't be bothered dealing closely with the actual DOM - ever."
I wouldn't hold my breath - Compiler Optimization Umbrella #9223.
Also Scheduling:
i.e. the design philosophy prefers run time control over compile time commitment.
I've just written a post about it here
But you can have stateful function components with hooks and using hooks makes a component impure, right? Technically yes, but in practice not really as I touched upon here.