[Paper Review] An Architecture for Making Object-Oriented Systems Available from Prolog
This paper presents a generic architecture enabling seamless integration of external object-oriented (OO) systems—particularly GUI libraries—into Prolog by exposing OO objects and methods as first-class entities within Prolog. The approach uses a lightweight, type-safe interface that maps Prolog terms to OO objects, allows method invocation across the boundary, and supports full debugging and incremental development, achieving low-latency communication (1–5.2 μs per call) while enabling pure Prolog development of both application logic and GUI components.
It is next to impossible to develop real-life applications in just pure Prolog. With XPCE we realised a mechanism for integrating Prolog with an external object-oriented system that turns this OO system into a natural extension to Prolog. We describe the design and how it can be applied to other external OO systems.
Motivation & Objective
- To address the challenge of integrating powerful external object-oriented GUI systems into Prolog, which lacks native support for efficient GUI development.
- To eliminate the need for separate, manually maintained bridges between Prolog and external GUI code by enabling direct, transparent access to OO systems from Prolog.
- To allow Prolog programmers to develop both application logic and GUI components entirely in Prolog, using the same language and tools.
- To support dynamic creation of classes and methods at runtime, enabling rapid prototyping and seamless extension of the OO system from within Prolog.
- To preserve full debugging and incremental development capabilities in Prolog despite the presence of foreign code and event-driven GUI interactions.
Proposed method
- The architecture defines four core Prolog predicates: `new/2` for object creation, `send/3` for method invocation, `get/3` for attribute access, and `is_a/2` for type checking, all abstracting the underlying OO system.
- It maps Prolog data types (atoms, integers, compound terms) to corresponding types in the target OO system (e.g., XPCE), with automatic conversion and type safety.
- The interface uses C as a common language bridge, leveraging C-compatible function pointers to call methods in the external OO system, ensuring performance and portability.
- The system supports dynamic method dispatch and runtime class creation, allowing new classes and methods to be defined and used directly in Prolog without recompilation.
- It integrates with Prolog’s native debugger by preserving stack context across foreign/Prolog boundary transitions and supporting breakpoints in both Prolog and foreign code.
- The design ensures that all application logic runs in Prolog, enabling use of Prolog’s incremental compilation and debugging tools throughout the development lifecycle.
Experimental results
Research questions
- RQ1How can Prolog be extended to natively and transparently access external object-oriented systems such as GUI libraries without requiring low-level C bindings or separate GUI code?
- RQ2What performance overhead is introduced by the Prolog-to-OO system interface, and can it be minimized to support interactive GUI applications?
- RQ3Can full debugging and incremental development be preserved when mixing Prolog code with foreign, event-driven OO systems?
- RQ4To what extent can object-oriented programming concepts—such as inheritance, dynamic method dispatch, and runtime class creation—be exposed and used from within Prolog?
- RQ5How can the integration support a unified development environment where both application logic and GUI components are written and debugged entirely in Prolog?
Key findings
- The Prolog-to-OO system interface achieves low-latency method calls, with execution times ranging from 1.0 to 5.2 microseconds per call on an AMD 1600+ processor.
- The performance overhead of calling a C-defined built-in method (e.g., `normalise`) is only 1.0 μs, demonstrating high efficiency suitable for interactive GUIs.
- The system supports full debugging of both Prolog and foreign code, with the SWI-Prolog debugger able to display interleaved stack traces across the Prolog-foreign boundary.
- Breakpoints can be set in both Prolog and foreign code, and the debugger can handle spontaneous event-driven calls (e.g., mouse drags) during execution.
- New classes and methods can be created dynamically at runtime in Prolog, allowing seamless extension of the external OO system without recompilation or source file generation.
- The architecture enables full, unified development of GUI and application logic in Prolog, eliminating the need for separate GUI and Prolog programs with complex interface synchronization.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.