Htmx and end-to-end declarative web programming Stream - Reply 1

this seems really interesting. Any followup on the work you managed to go over?


Anne has not been on this site since June of 2022 and I have not seen any public posting by her for a few years.

Annie got distracted with genocides and stuff, so hasn’t been around much.
I did build a toy version of this.
As it turns out you rarely want to get the information from the same place when you are doing an update to a page vs when you are doing a new load, and my example code ended up littered with special cases for each. So it’s one of those things that’s cool in theory but works less well in practice.

1 Like

In the need for a quick rather simple but interactive web page I gave a try. It is a perfect match for Prolog. Prolog is good at server side generation of HTML. The typical way to write JSON handlers in Prolog and the client in JavaScript is ok, but requires quite a bit of typing and the need to keep the server and client in sync. Using htmx all is together in the server.

I have added a very simple library(http/htmx), providing reply_htmx/1 that takes termified HTML as argument and creates an HTML reply without the entire page template. Otherwise the library is mostly there to point people at htmx as very little server support is required.

It is surely something to look at if you want to make a simple interactive web page and JavaScript is not your first language!


The sample code in library(http/htmx) has:

main(_Argv) :-

How is the call to thread_get_message/1 used?

(BTW, I changed it to call to prolog/0 so that I could dynamically add/remove debug logging)

Not at all. It just prevents the main goal complete and take down the server.