Programming in Prolog (3rd edition) by Clocksin, W.F. and Mellish, C.S.
Publisher: Springer Verlag
Prolog is one of those languages I've been curious about. I had two reasons for my curiosity. First, I try to follow the sound advice of the Pragmatic Programmers and learn a new language each year. To get the most out of it, the languages should be as diverse as possible. Second, I wanted to learn more about the roots of Erlang. At birth, Erlang was implemented as an interpreter in Prolog. Since then, Erlang has obviously come a long way, but its Prolog heritage is still quite prevalent.
My edition of Programming in Prolog is rather dated. The good thing about that is that it follows the old-style of programming books. Exemplary short and to the point. The book takes on a high pace and introduces most of Prolog in just 90 pages. Perhaps it would have benefited from more code samples and illustrative figures, but I cannot complain; the introduction is quite solid. But let's return to Erlang for a while. As an Erlang programmer, there's an air of familiarity over the Prolog code. Sure, logic programming is a different paradigm, but Erlang's syntax is still very close to Prolog's. And it's quite obvious where Erlang got its pattern matching from.
So, how's Prolog as a language? Prolog differs from most other programming languages by being a declarative language. As a programmer, you basically describe your problem in terms of facts and rules. Based on your description, Prolog attempts to find one or more solutions. Again, that's another point where Prolog differs from the mainstream by potentially delivering several solutions to a problem (similar to real life, actually). A Prolog program is basically a database searched by the language. If Prolog fails to find a solution, Prolog backtracks. Backtracking means trying alternate solutions in order to re-satisfy the goal. Another central Prolog term is the cut. A cut is used to limit backtracking by specifying which previous choices Prolog doesn't have to reconsider.
Programming in Prolog has been an interesting learning-experience, even if I'm yet to write any larger program in Prolog. Prolog is that kind of language; different enough to be interesting and small enough to slip in between the usual literature. The book does a decent job of teaching the basics and if I ever return to Prolog, I'll take the latest edition of Programming in Prolog as my guide.
Reviewed April 2010