Is Prolog worth learning? I learned and have used Datalog before in some projects, but never Prolog proper. What are some areas where it fits especially well?
I think it’s worth learning. If not prolog, any logic programming language is worthwhile.
Production Prolog and Evolving Prolog are a couple of interesting videos on Prolog usage in the real world.
Constraint solving is a good fit for prolog, using libraries like the clp(fd) module.
Goal planning and solving is a task it fits well. I wrote a small deployment system where the starting state of the machines were given to Prolog, along with a desired goal state and it would produce a list of commands to move the existing system to the goal. For example, 2 instances of httpd are the start state, 1 instance is the goal state, it produces commands to shut an instance down. Or it has packages A, B, C installed as a start state, I want packages D, E, F installed and it would produce the steps to do it.
Learning Prolog can help with learning different programming ideas. It’s fun to tinker with.
Reversable functions are interesting to learn about as a different way to think about approaching programming problems. Here’s an example of Reverse Factorial that computes the factorial for a number, or the original number given a factorial. Other logic languages can do this too. The same example in Picat and Mozart/Oz.
With Prolog you can explore Difference lists (See the Palindromes example here) or creating data structures where elements are logic variables to be bound later.
If you like Lispy languages then Prolog can fun used in a similar way - exploring from a REPL and using metaprogramming to generate progams.
That deployment system sounds really neat; is is available anywhere? If not, would you be willing to talk about it some? I’m sure it would make a neat submission here.
Unfortunately I’m unable to share the code, but I do plan to write up something about it with a simplified version of it. It’s in my queue of partially written blog posts that I’ve not had time to finish.