Skip to main content
QUICK REVIEW

[Paper Review] Portability of Prolog programs: theory and case-studies

Jan Wielemaker, Vı́tor Santos Costa|arXiv (Cornell University)|Sep 20, 2010
Software Testing and Debugging Techniques10 references3 citations
TL;DR

This paper presents a practical framework for achieving high portability of Prolog programs across major ISO-compliant Prolog systems—SWI-Prolog, YAP, SICStus, and Ciao—using conditional compilation and abstraction layers. The key contribution is demonstrating that real-world applications, such as the Alpino natural language processor, can be made fully portable with minimal conditional code, achieving cross-platform compatibility without major rewrites.

ABSTRACT

(Non-)portability of Prolog programs is widely considered as an important factor in the lack of acceptance of the language. Since 1995, the core of the language is covered by the ISO standard 13211-1. Since 2007, YAP and SWI-Prolog have established a basic compatibility framework. This article describes and evaluates this framework. The aim of the framework is running the same code on both systems rather than migrating an application. We show that today, the portability within the family of Edinburgh/Quintus derived Prolog implementations is good enough to allow for maintaining portable real-world applications.

Motivation & Objective

  • Address the long-standing problem of Prolog program non-portability due to dialect-specific differences in syntax, libraries, and system interfaces.
  • Reduce vendor lock-in and improve interoperability between major Prolog implementations, especially those derived from the Edinburgh/Quintus lineage.
  • Demonstrate that high portability is achievable in practice, not just in theory, through case studies of real-world applications.
  • Identify and resolve key incompatibilities in core features such as term serialization, threading, Unicode, and foreign language interfaces.
  • Propose a sustainable framework for ongoing portability improvements through collaboration with system vendors and standardization of commonly used predicates and flags.

Proposed method

  • Use conditional compilation via Prolog's if/1 directive to selectively include code based on the target Prolog system, enabling platform-specific implementations within a single source base.
  • Leverage Prolog's reflexive capabilities (e.g., dynamic predicate manipulation) to replace external configuration tools like GNU autoconf, enabling self-diagnosis of system features at runtime.
  • Implement portable abstractions for non-portable features such as GUI interfaces (tcl/tk), file I/O, and term serialization, using emulation or reimplementation where necessary.
  • Develop a shared interface layer for critical system features (e.g., file name resolution, message delivery, Prolog flags) to decouple application logic from implementation-specific details.
  • Extend core systems (e.g., SWI-Prolog) with minimal changes to align behavior with other systems, particularly for features like write_term/3 output formatting and UTF-8 support.
  • Apply the framework to real-world applications like Alpino, modifying only 59 conditional compilation points across 19,000+ lines of code to support both SWI-Prolog and SICStus Prolog.

Experimental results

Research questions

  • RQ1To what extent can Prolog programs be made portable across major ISO-compliant Prolog systems without major refactoring?
  • RQ2How effective is conditional compilation using Prolog’s if/1 directive in managing system-specific differences in libraries and system interfaces?
  • RQ3What are the major technical barriers to portability in Prolog, and how can they be systematically addressed?
  • RQ4Can real-world, complex applications like Alpino be ported across Prolog systems with minimal changes and full functional equivalence?
  • RQ5What role do vendor collaboration and standardization play in improving cross-implementation compatibility?

Key findings

  • The framework enables full portability of complex real-world Prolog applications like Alpino across SWI-Prolog and SICStus Prolog with only 59 conditional compilation directives across the codebase.
  • The Alpino application was successfully ported to both systems with no changes to its C code and minimal changes to Prolog code, relying on conditional compilation and abstraction layers.
  • SWI-Prolog was enhanced to support UTF-8 and correct term formatting in write_term/3, aligning its output with SICStus to resolve a critical incompatibility.
  • The tcl/tk interface was successfully reimplemented as a portable library, replacing a 17-file emulation of Ciao’s interface, reducing complexity and improving maintainability.
  • The performance of SWI-Prolog’s message queues improved significantly after rewriting from pthread-win32 to native Windows APIs, eliminating a 100x performance penalty.
  • The authors conclude that portability among the four main Prolog systems is now comparable to C on Unix in the 1990s, indicating a mature and stable foundation for cross-platform development.

Better researchstarts right now

From reading papers to final review, dramatically reduce your research time.

No credit card · Free plan available

This review was created by AI and reviewed by human editors.