Previous | Table of Contents | Next |
Progress on Prolog has continued apace. The directions of progress can be classified into three groups: progress on implementation technology, progress on practical uses, and progress on variants and added features.
The earliest Prolog implementations were interpreters, but Prolog compiler technology has been widely available since the mid-1980s. The late 1980s and early 1990s saw great strides in making Prolog compilers and the code they generate more efficient. Modern Prolog compilers are comparable in compilation efficiency and code efficiency to functional programming compilers.
Prolog was applied originally to AI problems, and its most widespread commercial use still is as a language for programming expert systems. However, it has also been used as a basis for language translators, interpreters and compilers, automated design, deductive databases, computer-aided instruction, natural language front ends, schedulers, and so on. In fact, Prolog has been found to be suitable for many applications involving complex symbolic processing and search for solutions. A Practical Applications of Prolog conference is held every year to promote interaction among the users of the language.
Many added features, variants of Prolog, and similar languages to Prolog have been proposed over the years. The added feature that has met with the widest acceptance, even in commercial Prolog compilers, is definite clause grammars, which allow users to write parsers in a very natural style. Three of the more popular non-commercial languages in the Prolog mold in recent years are XSB Prolog, which offers more flexible search strategies, and Goedel and Mercury, which offer types to assist in compile-time processing. More academic add-ons include constraint processing (allowing more natural expression of arithmetic relations, among other things) and parallel processing, but these are available mostly in experimental implementations with limited environmental support. However, research on constraint processing in the context of logic programming has had the side benefit of leading to industrial-strength constraint tools for imperative languages, such as Ilog Solver.
Finally, an international Prolog standard has been developed, although as far as I am aware, no free implementation of the standard is available. Information on the standard can be found via the Internet.
As a consequence of its history, Prolog is often known about, but seldom thoroughly known. Some myths have therefore arisen about the language and why it is not used in some circles. This is not to say that Prolog has no problems at all. Here I deal with some of the myths and discuss the real problems.
6.1.3.1. Myths
The biggest myth about current Prolog implementations is that they are slow. This impression may come partly from experience with old Prolog interpreters. As noted previously, with a proper compiler, Prolog is competitive with functional languages in speed. Another contributing factor may be the seductiveness of Prologs logical syntax; it is possible to write a natural-looking program that is nevertheless executed by Prolog in a very inefficient manner. To use Prolog effectively, it is sometimes necessary to re-express parts of a program in a way that ensures efficient execution, but it is often possible to do so.
The second biggest myth is that Prologs depth-first, backtracking search strategy makes it inadequate for the tasks it is supposed to perform. This is a holdover of the old AI debates about Prolog and only really applies if we expect to be able to code up our problem domain in logical formulas and have Prolog execute it as-is. We do have to take the search strategy into account when writing Prolog applications, but the same applies to imperative or functional languages, with their depth-first, non-backtracking execution model. Prologs backtracking is a tool that we can use whenever we need it but set aside when we dont.
One of the strangest myths about Prolog, still spotted on the Internet from time to time, is that we can easily write a Prolog interpreter in Lisp but we cant easily write a Lisp interpreter in Prolog. This myth has been refuted several times, and various simple Lisp interpreters written in Prolog are now available on the Internet.
6.1.3.2. Problems
There do remain two major problems with most Prolog implementations. The first is that classic Prolog has no type system. This makes for great programmer freedom, but also for runtime errors similar to those that programmers in typeless Lisp variants have to deal with. Many logic programming systems have types, but these systems are rarely industrial-strength. Goedel and Mercury are two of the best.
The second problem is that classic Prolog has no notation for defining functions, just relations. For instance, the factorial function can be expressed easily in a functional language as a function fact(X) taking an integer X and returning an integer, but in Prolog, it must be expressed as a boolean relation fact(X, XFact) relating an integer X to its factorial XFact. Of course, any function taking N arguments can be defined as a relation of N+1 arguments. But it is often more convenient to define a function and then use a call to the function directly in an expression. Many proposals have been put forward over the years for merging functional and logic programming, but no one proposal has caught on and been widely accepted.
Prologor the languages that succeed itwill have to deal with these problems eventually as the logic programming paradigm evolves.
Many commercial and freeware versions and variants of Prolog are available, with the usual tradeoffs among power, cost, and usability. I recommend that interested users search for the Prolog Resource Guide on the Internet to get more information.
Many books have been written about Prolog from different perspectives. All of them go into more detail about the use and features of the language than this brief chapter is able to do. Some of the best, in my opinion, are the original classic, Programming in Prolog, by Clocksin and Mellish (1987); the more advanced books The Art of Prolog by Sterling and Shapiro (1986) and The Craft of Prolog by OKeefe (1990); and the application-oriented Prolog Programming for Artificial Intelligence by Bratko (1990).
As well, online Prolog tutorials have been springing up on the Internet in various forms. Use your favorite search engine to find the latest.
Previous | Table of Contents | Next |