Why Erlang as an inspiration for Web Prolog?

2026-10-31

One objection I have encountered is that Erlang is not a particularly good source of inspiration for adding concurrency to Prolog. After all, there are other ways of doing it.

Of course there are. The Prolog world has a rich history of approaches to concurrency and parallelism: AND- and OR-parallelism, concurrent logic programming with dataflow and committed choice, threads with shared memory, and various forms of message passing. These are interesting approaches, addressing different needs. But listing alternatives is not, in itself, an argument against Erlang. The question is: what kind of concurrency do we want, and for what purpose?

My goal with Web Prolog, the language at the heart of the Prolog Trinity Ecosystem, is to make Prolog a language for distributed programming on the Web. That involves more than making an individual computation run faster on multiple cores. It involves independent Prolog processes with their own lifecycles, communicating with one another across machines.

This is where Erlang becomes particularly interesting.

A model for communicating processes

Erlang offers a coherent starting point: isolated processes, asynchronous messages, selective receive, and established mechanisms and patterns for monitoring, supervision, and recovery. Distribution and failure handling are central concerns of the programming model.

For Prolog, this suggests an attractive combination: retain unification, logical variables, and backtracking within each process, while organising cooperation between processes through message passing. We can preserve ordinary Prolog execution within a process while giving processes a way to participate in a larger concurrent system.

This distinction matters. A process can search for solutions, backtrack, and produce successive answers. Other processes can ask it questions, consume those answers, or carry on with their own work. The coordination of these activities does not require us to replace Prolog’s ordinary search with committed choice throughout the language.

There are boundaries to respect, of course. Backtracking within a process does not undo a message already sent to another process. Nor does a uniform messaging interface make network delays, broken connections, or partial failures disappear. Those are part of what the design must address.

None of this requires copying every detail of Erlang. Taking inspiration from a language is hardly a pledge of allegiance to all its design decisions. It means recognising a useful combination of ideas and adapting it to the language and environment we actually want to support.

What would make an alternative better?

Other approaches deserve to be assessed on their own merits. AND- and OR-parallelism can help exploit parallelism within a computation. Dataflow and committed-choice languages offer their own ways of expressing concurrent activity. Shared-memory threads can be useful within a single runtime. These approaches can also be combined with other mechanisms; they are not mutually exclusive camps.

For Web Prolog, however, the questions I want an alternative to answer are concrete. How does it organise independently running Prolog computations across machines? How do they exchange requests and results? What happens when one terminates, becomes unreachable, or needs to be restarted? And how much of ordinary Prolog can programmers retain within each computation?

Erlang provides a substantial body of experience relevant to those questions. That is the case for taking it seriously as an inspiration.

And one more ingredient: the Web

There is a third ingredient in my proposed combination: the Web itself. Prolog and Erlang-inspired processes give us an interesting starting point for concurrent and distributed programming. With Web Prolog, I want to explore that combination specifically through HTTP and WebSockets, making the Web the environment in which those processes and their clients meet.

Part of that choice is quite personal and pragmatic. HTTP and WebSockets are technologies I know; other approaches to implementing distribution are less familiar territory for me. I am happy to admit that. Building on the Web was a natural starting point. But the attraction goes beyond familiarity: it connects the language to browsers, web servers, and the wider ecosystem of web applications. The ambition is to make Prolog computations and communicating agents accessible through that existing environment.

Nor am I claiming that combining Prolog with distributed message passing is new. Qu-Prolog is an important predecessor: Keith Clark, Peter J. Robinson, and Richard Hagen described its support for multiple threads and internet message communication in their 2001 paper, Multi-threading and message communication in Qu-Prolog. The web already existed in 2001, but WebSockets did not: the WebSocket protocol was standardised a decade later, in December 2011, as RFC 6455. That difference matters. WebSockets provide persistent, bidirectional communication between browsers and servers, making them a natural fit for the message passing I want to support. My emphasis is on bringing these earlier ideas into a programming model built around HTTP and WebSockets, using capabilities that were not available in that form to Qu-Prolog’s designers at the time. That is what makes the combination particularly interesting to me: Prolog, Erlang-inspired concurrency, and the Web.

Towards a common language between Prolog systems

The Web also gives the project a larger purpose: interoperability between Prolog implementations. I would like Web Prolog to become a lingua franca through which systems can expose relations, exchange goals and answers, and address communicating actors. Agreement at these interaction boundaries would let implementations retain their own strengths while participating in a shared environment.

Participation should be incremental. A system could begin by exposing relations through the stateless HTTP interface, then add richer capabilities as needed. Supporting the complete actor model should not be the price of admission.

For actors, the corresponding ambition is a common interaction model across locations. Spawning, sending, receiving and monitoring should remain recognisable whether an actor runs on a native node, in a browser worker or on another machine. Location still affects latency and possible failures; it should not require an entirely different way of programming cooperation.

There is a useful connection here with Hans Svensson, Lars-Åke Fredlund and Clara Benac Earle’s 2010 paper, A Unified Semantics for Future Erlang. They proposed a cleaner semantics addressing the division between local and distributed Erlang. Trinity does not implement their formal semantics, but shares the aspiration to treat local and remote interaction more uniformly. This is another reason to see Erlang as a source of ideas that can be developed further.

HTTP and WebSockets supply communication mechanisms. The larger proposal is to build common Prolog interaction contracts on top of them, so that different systems can cooperate across the Web.

So I am happy to discuss other models. But the interesting objection is not that alternatives exist. It is why a particular alternative would better serve this goal: independent Prolog processes collaborating over the Web.