Quick check: Is the swiplwebtut still good for learning server setup?

Hi quick question: I see the swiplwebtutTutorial — Creating Web Applications in SWI-Prolog” was last updated 3 years ago. Is it still pretty much comprehensive to go through and learn how to set up an swi server? Does it pretty much cover most everything needed? Anything missing or any significant changes from the last 3 years?

Thanks.

The overall idea is pretty much ok still. Some libraries have evolved a little. The most obvious changes are in managing websites. Generations a lot of HTML on the server is getting less popular. Many applications are Javascript based and run JSON requests on the server. SWI-Prolog can do that quite well. The stress of the web trutorial is more on generating HTML though.

My attempt to update it is here:

There is (fortunately for the tutorial?) kind of a movement back towards generating server-side HTML and “patching” updates on the client (see Hotwire, HTMX). I’ve written some little things in Prolog using this approach.

2 Likes

FWIW, the “tutorial” code that I wrote has a static HTML file (static/simple_client.html) with an id= for each path that will be filled in dynamically. The function displayQueryResult() (in static/simple_client.js) is a callback that gets the server’s result in JSON and uses the JSON to fill in the HTML. (The code would probably be a bit simpler if SWI-Prolog’s HTML write library were available on the client, but that would require rewriting my JavaScript code into Prolog, something I might do one of these days. Or, the HTML could be generated in the server and sent as a string; but I prefer to separate front-end and back-end representations.)

A more complete example is in pykythe/browser at master · kamahen/pykythe · GitHub … it uses the same structure as my “tutorial” code but has a more complex browser layout (drop-downs, resizable panes) and more query types (they all use the same fetchFromServer() function with an asynchronous callback).

Haha awesome. Gonna do some light reading about that. I’m gonna go ahead and believe prolog is simply more cutting edge than the status quo, rather than outdated or less popular.

2 Likes

Here’s an example of my version of that idea from a couple years ago.

1 Like