Surprisingly, an imperative GUI creation code is much more easier to read and modify.
The best analogue to "declarative" in desktop ui terms would be to have your dom templates in separate files that you don't manipulate the structure of in code.
I honestly have an overall negative view of react, but its method for letting you declare ui structure is really fantastic.
Moreover, Declarative UI enables the development of powerful tooling and visual editors. For instance, in Slint, we have an extension that provides live UI preview and code transformation capabilities. We are also actively working on a visual editor that lets users drag and drop widgets. Such capabilities are difficult or impossible to achieve with imperative APIs.
If you are interested in talking about this, do let me know.
I don't think you have ever used an imperative API, have you?
I used VB, then Delphi, then C++ builder and now use Lazarus, and there's no declarative equivalent that is easier or faster than those.
This is the statement I was contending:
> We are also actively working on a visual editor that lets users drag and drop widgets. Such capabilities are difficult or impossible to achieve with imperative APIs
Maybe I should have said "there's no declarative-only equivalents that's easier or faster".
As someone else pointed out elsethread, declarative is a subset of imperative, so it's easy to produce an imperative API that consumes machine-generated declarations, but not so easy to use a declarative-only framework to reproduce the ease and speed of Delphi, Lazarus, etc.
The overall layout of the GUI is designed using a GUI designer and this gets saved as a "form" in a resource file which is loaded at run time and so the actual code does not have a lot of declaration of the GUI but it is read in as a stream from a separate resource file.
However, to this GUI, you can add event handlers, add or remove components at run time etc. All of this is quite clumsily done (IMHO) in frameworks such as flutter.
What kind of feature set do you need?
That's not to dismiss subpixel rendering, there is arguably a legibility improvement to trading off color accuracy for horizontal resolution, but it's really no wonder that new frameworks don't bother and that old frameworks are losing the ability to do subpixel rendering. Apple, for example, ripped out subpixel rendering from their frameworks a long time ago (before Retina displays, IIRC).
...or at least when Retina displays were still rare and expensive, probably to encourage the adoption.
I agree.
It seems like we have some good solutions for declaratively describing the structure and static appearance of UIs - but beyond things like transition animations, we don't have anything that satisfactorily describes their behaviour. Its a hard problem nut I sometimes wonder why this aspect is under-served by the technologies we have.
…but I mean, that’s an opinion that is not falsifiable.
If the author disagrees, that’s up to them right?
I agree with the author too; after using xaml, my taste for declarative UIs is limited.
Here’s something that is falsifiable: what is possible using declarative UIs is a strict subset of what is possible using imperative code.
If your declarative config is Turing complete, it’s a DSL; ie. a programming language, not declarative and you’re in “not invented here” land.
If not, the possibilities for it are a subset.
That’s provable; so, if you’re worried that your UI is too complex to easily represent with the existing declarative structure, go for code.
What if you need dynamic layouts? What if your layouts are determined at runtime by dynamically loaded plug-ins? What if your layout needs to generated differently based on themes, or screen sizes? Who knows?
It seems entirely reasonable.
The same goes for other declarative solutions and projects. Eg. Terraform.
I mean, the author literally says a) it’s a trade off for velocity, b) they’re more concerned with performance, c) the implementation in slint is not complete and d) they’re considering writing a very very low level UI library to get what they want.
…maybe, they just want different things to what you’re offering?
It doesn’t mean they’re “wrong”.
> The author seems to dismiss declarative UI without explaining why.
> From my perspective, declarative is the best way to describe UI.
I think it's pretty clear that the writer here believes that the OP is wrong about slint and declarative UIs.
My point is that OP is not wrong; declarative UI is not the best way of doing UI for all use cases.
It is simply one way of doing UI.
An application like Photoshop is comprised of relatively simple controls (property sheets, etc.) that are combined in complex ways. (Users can add UI elements such as a color picker, dock them, have them floating in space.) Graphical UI builders are fine for the controls, but there has to be some framework for managing the particular set that is on the screen.
I stand by what I said: most plugins have nowhere near the complexity of a DAW. Some do! (Kontakt/Reakt, and so on) but the vast majority only have a small subset of what the DAW needs to display, and only need to do it for a limited number of channels, and only need to do it rarely.
I'm a bit disappointed to see that Slint is considered a non-starter. In fact, one of our users is currently working on exactly that (a VST plugin for an audio application) and they are about to release it very soon. Unfortunately, I can't share a link until it's officially released.
The author seems to dismiss declarative UI without explaining why. From my perspective, declarative is the best way to describe UI.
Regarding the limited support for custom widgets, I disagree. In Slint, it's incredibly easy to create custom widgets. A widget is simply a component that can be created and utilized.
While it's true that our desktop integration is still a work in progress, we have already implemented the core functionalities needed for building such UIs. We are actively developing features based on user needs and prioritize implementing features that our users require immediately. If you're interested in using Slint, please reach out to us, and we'll ensure that we implement what is necessary for your product.