3 ms·
> Current best practices often involve a more imperative style of programming, while HTMX, on the other hand, is more declarative. > This is a fundamentally ne
by talldayo 3y ago
> Current best practices often involve a more imperative style of programming, while HTMX, on the other hand, is more declarative.
> This is a fundamentally new approach to interface design
Which "best practices" are imperative, these days? I don't build many advanced web UIs but my impression is that most professional interfaces are handled with declarative XML-style schemas. It's hard to shake the feeling that this is a reinvented wheel...
- dphuang2 3y agoActually, you are right. I must have had a freudian slip when I was thinking about React's conditional rendering pattern (https://react.dev/learn/conditional-rendering https://react.dev/learn/conditional-rendering). But I realize this is actually declarative. I think what I was trying to convey was that React involves more in-memory state management while HTMX embed that state in the HTML itself, which can be a jarring perspective shift in frontend programming. I'll fix this sentence so I don't confuse any future readers. Thanks for the catch!
- mejutoco 3y agoTo be fair, while jsx (assuming you mean that one) indeed look like xml, the variables that get interpolated in it come from js code. Same with the events that are triggered and their callback functions. One could argue defining what gets updated on which event via attributes (htmx) is more declarative. On the other hand, it is not fully declarative because the server is rendering the html code with the attributes. But OP argued for more declarative, which I think it is fair.