I can't understand the logic for this
I can't understand the logic for this
Posted Aug 19, 2024 5:04 UTC (Mon) by ssmith32 (subscriber, #72404)In reply to: I can't understand the logic for this by yeltsin
Parent article: COSMIC desktop makes its debut
React is not a declarative model, even moderately. Maybe slightly if you squint really hard after too many drinks? But it's mostly *not* declarative.
It's very much an imperative language that lets you build components.. similar to how most object-oriented UI frameworks work. If you stretch the definition of declarative enough, maybe? But then GTK would be considered declarative...
But you very much tell it to
Build component A,
then connect it to component B,
when you get signal X, then update Y, etc.
Step by step, in an imperative fashion.
Having abstractions and components != declarative.
SQL is probably the closest thing to declarative that most folks are familiar, and it's nothing like building a React app, and is absolutely *atrocious* for building large apps out of. Large SQL queries are usually much less maintainable than code of any sort of a similar size.
Prolog is also much closer to declarative than React. And is also absolutely horrible for large programs.
A declarative language for UIs would let you declare what you want to accomplish, literally, something like: "A UI to let me update the time and timezone on COSMIC"... and then the optimizer goes off and builds that UI.
React, you have to tell it exactly what you want, and, most importantly, how to handle input, step by step. That's imperative.