Next: How Does a CLP
Up: What is Constraint (Logic)
Previous: An Example: SEND +
The last example shows that Prolog syntax (and semantics) and finite
domains go quite well together. Actually, it is more than that: due
to the incremental nature of constraint programming (prototyping and
building an application incrementally is easy and natural), the
availability of interactive interpreters for CLP languages (inherited
from Prolog) is a plus, as experimentation and debugging are parts
inherent to the development of a program.
Also, the built-in backtracking of logic programming allows the easy
customization of search procedures for the cases in which standard CLP
procedures are not good enough: this may happen when there are hints
as to what is the best direction to search in. Small examples might
not show that, due to small search times, but large examples often
make the difference apparent.
Some interesting characteristics from Prolog are also inherited, which
are not found in other languages:
- A built-in database, which can be used (with caution) to
implement global variables, but whose main strength is in saving
intermediate results which do not need to be recomputed
(lemmas) and, in the extreme, to generate and change program
code dynamically.
- Meta-programming facilities, which allow the program to be
managed as if it were data, examine its code while running, calling
goals and collecting the solutions produced on backtracking, and
other goods which are only available to logic programming.
- Easy definition of meta-languages and easy developing of
interpreters for those languages. This allows the user to create a
high-level language suited for her/his needs, with which developing
the final application will be easier, and to code an interpreter for
such a language.
Of course, there are some disadvantages in using Prolog as host
language, mainly concerned with the difference of the logic
programming paradigm with respect to other paradigms:
- It might be not as well accepted as other languages: Prolog is
sometimes not part of standard curriculum in Computer Science, and
therefore some training is usually needed, and some programmers
might be reluctant to undertake learning a new paradigm.
- There are notable differences with respect to conventional
languages in the way data structures are handled: but these
differences, in the end, favor the programmer, for they turn out to
be easier to work with and to define, and more secure in what
respect errors caused by illegal memory accesses, etc. Control is
also quite different: the embedded search, once understood, is a
very powerful way of programming.
Last, but not least, there are different products which implement the
CLP paradigm. Depending on the problem some of them might be more
adequate than others. But very probably the final application in an
industrial environment will have to interact with other programs, so
the possibility of having an interface (other than a raw text file) is
a point to take into account. Fortunately this is the case for all
commercially available Prolog and CLP systems.
Next: How Does a CLP
Up: What is Constraint (Logic)
Previous: An Example: SEND +
MCL
1998-12-03