Logtalk 2.18.0

Paulo Moura
Dep. De Informatica -- Universidade da Beira Interior



Logtalk is an open source object-oriented extension to the Prolog programming language. Integrating logic programming with object-oriented and event-driven programming, it is compatible with most Prolog compilers. It supports both prototypes and classes. In addition, it supports component-based programming through category-based composition.

Highlights of the latest release

Logtalk 2.18.0 features much improved performance for most Prolog compilers. This was accomplished by applying several optimizations to the runtime translation of messages and, specially, by caching method lookups. In addition, this release includes improved configuration files for both ECLiPSe and XSB.

Logtalk major features

Logtalk objects provide plain Prolog with two essential features: encapsulation and code reuse. Plus, Logtalk adds to these two basic features the following ones: reuse through inheritance and composition; separation between interface and implementation; public, protected, and private inheritance; multi-inheritance; public, protected, and private predicates; static and dynamic object predicates; parametric objects; static and dynamic objects; support for multiple object hierarchies; support for both classes and prototypes; standard Prolog syntax with the addition of a few operators and directives for a smooth learning curve; event-driven programming; automatic generation of documentation files in XML format; and a built-in debugger.

Is Logtalk compatible with my favorite Prolog compiler?

Logtalk provides configuration files for most Prolog compilers. Currently, twenty compilers are supported: ALS Prolog, Amzi! Prolog, B-Prolog, Bin Prolog, Ciao, ECLiPSe, GNU Prolog, If-Prolog, K-Prolog, LPA Mac Prolog, LPA Win Prolog, Master Prolog, Open Prolog, Prolog II+, Qu-Prolog, Quintus Prolog, SICStus Prolog, SWI-Prolog, XSB, and YAP. This broad compatibility makes Logtalk an ideal tool for writing portable applications.

Why use objects instead of modules?

Logtalk objects, as described above, support a number of features that are simply not available with Prolog module systems. These features, resulting from a reinterpretation of both fundamental and innovative object-oriented concepts in the context of logic programming, provide a proven framework for developing large Prolog applications. Powerfull support for code encapsulation and code reuse is a most for any programming language. Prolog is no exception. Another reason to prefer objects instead of modules is portability. Not all Prolog compilers support modules. In addition, there are several compatibility problems between the modules systems of the major Prolog compilers regarding basic features such as locality of operator declarations and definition of meta-predicates. Furthermore, the ISO standard specified Prolog module system is incompatible with most of Prolog module systems in use today.

Converting Prolog code which uses modules to Logtalk objects can easily be performed by replacing module directives with object directives and by replacing declarations of exported predicates with public scope predicate directives. Logtalk objects can be defined in source files as stand-alone entities (i.e not integrated in some hierarchy), compiled, and used at runtime the same way as modules. Using Logtalk objects does not necessarily imply the use of dynamic code or forgoing the guidelines we use when developing Prolog applications. Encapsulation and code reuse are orthogonal features to the dynamic aspects of objects on traditional object-oriented languages.

Why a pre-processor implementation?

Logtalk is currently implemented as a Prolog pre-processor. This translates to a two passes compilation: first, from Logtalk to Prolog and then from Prolog to whatever format your favorite Prolog compiler uses. A pre-processor implementation allows users to take advantage of special features only available on some Prolog compilers. As such, Logtalk development can be focused on object-oriented features instead of trying to be everything for everyone. Furthermore, by being open source and implemented in Prolog, users have always the option of customizing Logtalk to better fit their needs.

How about performance?

Logtalk objects can be either static or dynamic. Static objects are defined in source files which, upon compilation, are converted to static Prolog code before being further compiled by your favorite Prolog compiler. Furthermore, static Logtalk objects may contain dynamic predicates allowing locality of database changes. The Logtalk compiler ensures that your programming choices related to first-argument indexing and tail recursion are keep on compiled code. At runtime, Logtalk caching of method lookups ensures performance levels close to what can be achieved with Prolog modules and with static binding on other object-oriented languages.

What do I get with the current Logtalk release?


The current Logtalk release contains thirty three programming examples (ranging from basic object-oriented concepts to traditional Prolog and AI applications; most of them potentially useful in a classroom context), a library of useful objects, protocols (interfaces), and categories (components for building objects), syntax-coloring configuration files for common text editors (including Emacs, Vim, Kate/KWrite, SubEthaEdit, NEdit, jEdit, and others), and integration scripts for automatic loading of Logtalk with some Prolog compilers.

How to learn more about Logtalk?

For more information on Logtalk and for downloading the latest release, please visit the Logtalk web site at http://www.logtalk.org/.