First published at 18:09 UTC on June 1st, 2021.
MORE
https://github.com/Anniepoo/swiplwebtut/blob/master/web.adoc
This course is for anyone who knows SWI-Prolog reasonably well and wants to learn the web application framework bundled with SWI-Prolog. You will also need some fluency with web development basics like HTML, CSS, and HTTP.
Many programmers assume Prolog needs to be hosted with a normal language. I’m not sure why. Certainly xpce wouldn’t be suitable for many desktop gui systems. But those are becoming rare. Even the desktop systems I’ve written recently have been written as web servers that display the UI in the browser. This course is part of my response to this mentality.
1.4. Why Prolog?
Prolog is of course more associated with expert systems and torturing undergraduates than with production web applications. But I’ve found it an excellent system for building web applications as well.
Prolog programs are simply smaller . Prolog programs are often one tenth the size of equivalent Java programs. And smallness is a virtuous cycle. Smallness encourages well written code, and well written code is easier to maintain and refactor and remains small.
What makes Prolog systems small? Complex question, but we can identify various factors. With backtracking instead of control structures, Prolog eliminates the 90% of loops that are actually iterators. Backtracking often eliminates error handling. Partial binding and incomplete structures eliminate much data reformatting. And in general, there’s just a lot more case based reasoning, which means a lot less ceremony associated with handling of edge conditions. And of course you can put a small reasoner in to figure out complex business logic like who’s allowed to edit this?
The SWI-Prolog web app framework is very friendly. You can edit running code and query make. (C-c C-m in the IDE editor) and keep going without disturbing state, and you can use the graphic debugger.
1.5. Does Anybody Actually Use This?
All these systems are in Prolog, using the web framework described in this tutorial.
LESS