I originally learnt Prolog some 35+ years ago, and have recently come back to it. As it’s been so many years since I last did any, I was starting mostly from scratch. I have got some way, but am not advancing.
I learn better from books, rather than online, so I bought a copy of Clocksin and Mellish, which in those days was considered “the” book to learn Prolog.
However, from reading online, and a few questions I’ve asked, it seems that modern Prolog has come a long way since then, and a lot of what is in there is probably not relevant or best practices. For example, I see a lot of people saying that CLPFD is a basic part of modern Prolog programming.
Can anyone recommend a book that will teach me modern Prolog? I don’t mind an introductory one, as I am still fairly green with the language.
Think of CLPFD and other contratint systems as something that makes Prolog better. You still need to understand Prolog to effectively use such with Prolog.
I would also suggest “Learn Prolog Now!” and Logic programming with Prolog. They are very different texts, but I think they might be complementary in some way. They both have very short chapters focusing on a specific topic and then exercises and practical sessions to help the reader to test if/what he/she has learned
Modern Prolog is about the same as Ancient Prolog, with some new features and libraries on top. This is where it gets a bit messy: the different implementations have different extensions, with different degrees of compatibility. The same goes for libraries.
I wouldn’t know that it is possible to have one good book on Modern Prolog. Instead, you can take what you already know, solve the problem at hand, so that you understand your problem. Then, maybe spend a bit of extra time searching for other ways to solve the same problem. This is how you can explore new libraries and maybe extensions to Ancient Prolog.
Some examples for SWI-Prolog are Tabling, Strings, Dicts, Delimited continuations, Engines, Transactions (please someone extend the list!)… they are all documented to a degree that you can try using them. Some of those easily deserve a longish chapter in a textbook, I guess.
If you are interested in natural language processing, another textbook which covers in a rather extensive way Prolog and some of its features is An Introduction to Language Processing with Perl and Prolog by Pierre Nugues. But of course it’s more a text on language processing than on Prolog itself
exceptions (this was sort-of part of “old Prolog”) and predicates that help right robust code, such as setup_call_cleanup/3.
streams (replacing the old Edinburgh I/O)
Unicode support
Rational numbers
Global variables (backtrackable and non-backtrackable), replacing many uses of assertz/1 and recordz/3
Graphic debugger, editor interfaces, performance profiler, unit testing frameworks
Libraries for writing client/server (especially using HTTP)
WebAssembly implementation, for running Prolog in the browser
There’s also Logtalk, which " includes support for modules, prototypes, classes, protocols (interfaces), categories (components and hot patching), event-driven programming, and high-level multi-threading programming" and “can use most modern and standards compliant Prolog implementations as a backend compiler”.
There’s also Picat, “a mix of logic, functional, constraint, and imperative programming”. And, with a different approach to logic programming: Mercury (and Mozart, although I don’t think it’s being worked on much any more).
If you’re interested in constraint programming, you might also want to look at “answer set programming”. I wish there were more work being done on constraint and answer set programming, especially in the area of debugging and testing tools.
I should clarify that the term “modern Prolog” was my own invention, based on some comments I’d seen around that C&W was out of date, and not as relevant to Prolog programming as it used to be. Specifically, it was pointed out to me (can’t remember where unfortunately) that the way I was trying to solve a specific problem would be much easier using CLPFD (and indeed it was), and that I should learn Prolog with that, rather than learning from (say) C&M on its own. That was the basis for my question.
So, I’ve had some great recommendations here, and will have to go through them and see. I have spent a lot of time reading Markus Triska’s excellent site, and watching his videos, but one of the problems there (and what really prompted my question) is that in a lot of cases, he doesn’t really explain how to solve the problem, but rather shows code that solves it. The notable exception to that was the video in which he showed how to solve the n-queens problem, where his background explanation was excellent.
I was looking for a resource that gives that sort of approach, as that way I can learn the language and understand how to solve problems myself, rather than reading someone else’s pre-written code and trying to work out how it solves the problem. That does have its merits, but is not the best way to learn (for me at east).
Anyway, thanks again to all. If anyone has a specific recommendation (paper book is my favourite) that teaches how to solve problems in Prolog then I’d be grateful. If not, I’ll work my way through the many recommendations here and see what I find again.
If you want to know what happened to Prolog, have a look at Fifty Years of Prolog and Beyond It covers most of the history and progress behind the language and a lot more.
But, what is really lacking is a book/tutorial/… that explains how to use all the stuff that was added to the language after the ISO standard dating from 1995. For some of the stuff (notably constraints) there is still a book and tutorials. David S Warren started a book on tabling, but never quite finished it. There is a lot to say about using tabling with Prolog that is now mostly in the heads of a really small group of people About all the other extensions you might find some scientific papers and some documentation and hints in the documentation of several Prolog implementations, but that is about where it ends
B.t.w. the above article makes the claim that all in all the various Prolog implementations are not too different from each other. Although I’m a co-auther, I’m not sure I agree with this. It is true though that many systems tried to find answers to similar shortcomings of the “ISO” Prolog. It is also true that it is quite doable to write portable code using various of these extensions, at least between a selection of Prolog systems. Logtalk may help here.
As is, this forum is probably the best place to find (pointers to) answers on most of these things