Something like Pengines in SWI Prolog

Suggestions for new Logtalk features

Moderator: Paulo Moura

Post Reply
hnbeck
Posts: 4
Joined: Sat Jul 25, 2020 6:21 pm
Location: Stuttgart
Contact:

Something like Pengines in SWI Prolog

Post by hnbeck »

Hi all,

after some initial problems I'm very happy to be here :)

One thing I would like to discuss. The forum "Wishlist" may not be the best, but it could be seen as a wishlist for Logtalk.

I'm playing arround with SWI Prologs Pengins package. This is a nice tool to connect a web application (HTML/JS) with Prolog, and I have also projects to connect Python and C#. But Pengines has its problems and is special to SWI Prolog.

It would be nice if there could be some objects in Logtalk which can talk remotely, together, using a standard protocol (http, websocks....)
Or I coudl express my wish in a more solution free way: I wish a simple possibility ot connect Python, C# or aother languages with Logtalk apps (independend of the backend) in the sense that Python or C# or JS (or whatever) send messages to a Logtalk appl

Of course, backend independent can only be as long the backends provide at least a socket access. But I think you understand my intention :)

Cheers

Hans

Paulo Moura
Logtalk developer
Posts: 526
Joined: Sat May 05, 2007 8:35 am
Location: Portugal
Contact:

Re: Something like Pengines in SWI Prolog

Post by Paulo Moura »

This have been discussed a few times in the past. I once made a proposal for standardizing Prolog foreign language interfaces at the Prolog Common initiative. But there was no followup and the Prolog Common initiative eventually died.

Only a few Prolog backends provide a sockets interface. There's no standard and the interfaces differ. Logtalk provides a "redis" library that, due to these limitations, can only be used with GNU Prolog, Qu-Prolog, SICStus Prolog, SWI-Prolog, and XSB backends. It would also support ECLiPSe if they fix some bugs (long overdue). This library only uses a subset of the sockets predicates but still cannot be used in half of the backends.

I fully realize how much this lack of Prolog standardization limits what you can do in a portable way from Logtalk. Hard to make progress when most Prolog systems don't really care much about standardization. These are the kind of issues that sadly often results in applications running in a single backend.

It may, just may, be possible to improve this situation by abstracting from the backends foreign language interfaces. But that's a challenging task and there are currently no resources available to explore such a solution.
Paulo Moura
Logtalk developer

hnbeck
Posts: 4
Joined: Sat Jul 25, 2020 6:21 pm
Location: Stuttgart
Contact:

Re: Something like Pengines in SWI Prolog

Post by hnbeck »

Hi,

these are interesting and important points. I've looked a liitle bit around the describtions of other Prologs. It seems that there is a not small set of Prologs providing at least some multitasking and something like a socket.

Conclusion: using Logtalks capabilites of multi thread programming, it may reasonable to build something like Pengines or Erlang like process system with Logtalk for server applications. Ok, it may be that is works only with some Prolog backends, but I think there are good candidates for this :)

Do exist anywhere some Logtalk based server applications ?

Cheers

Hans

Paulo Moura
Logtalk developer
Posts: 526
Joined: Sat May 05, 2007 8:35 am
Location: Portugal
Contact:

Re: Something like Pengines in SWI Prolog

Post by Paulo Moura »

Logtalk multi-threading features requires a backend Prolog system implementing the ISO draft proposal for threads. The only systems doing it and doing reliably are ECLiPSe and SWI-Prolog (but the lack of a few key predicates means that ECLiPSe can only run the multi-threading engines examples, not the full multi-threading examples; this is a limitation that I don't expect to be fixed as the ECLiPSe developers refuse to implement the missing predicates). XSB deprecated its multi-threading implementation (which was broken for years). YAP's threads implementation have been buggy and thus unusable (for Logtalk purposes) for more than a decade. A few other systems (e.g. CIAO Prolog and Qu-Prolog) provide some multi-tasking support but not enough/usable for (the current version of) Logtalk. I don't see any practical way of doing portable Logtalk multi-threading applications that can even target two backends.
Paulo Moura
Logtalk developer

hnbeck
Posts: 4
Joined: Sat Jul 25, 2020 6:21 pm
Location: Stuttgart
Contact:

Re: Something like Pengines in SWI Prolog

Post by hnbeck »

Hi,

thank for this insight. This are bad news indeed. If I understand right then to fix the multitasking support in an Prolog implementation requires to implement the ISO threads.

Or in other words, SWI Prolog is the only (free) one where I can do mulitthreading/multitasking with Logtalk.

Thanks for this insight

Cheers

Hans

Paulo Moura
Logtalk developer
Posts: 526
Joined: Sat May 05, 2007 8:35 am
Location: Portugal
Contact:

Re: Something like Pengines in SWI Prolog

Post by Paulo Moura »

Logtalk threaded engine predicates can also be used when running with ECLiPSe (which is also open source) as the backend.
Paulo Moura
Logtalk developer

hnbeck
Posts: 4
Joined: Sat Jul 25, 2020 6:21 pm
Location: Stuttgart
Contact:

Re: Something like Pengines in SWI Prolog

Post by hnbeck »

Hi Paulo,

it seems that I have to read some more about threads, the problem with threads in Prolog and its difference to the process / thread model in Erlang. Even the difference thread to process - which are different things - are not clear to me on this point of the discussion :)

BTW. I've read the ISO WG17 draft for threads. Don't understand much at the moment :)

The state my problem arising in the last discussions in Twitter and here simple and short:

Why can't a system like Erlang be build in Prolog (when Erlang was born out of Prolog)

Cheers and thank you for the information

Hans

Paulo Moura
Logtalk developer
Posts: 526
Joined: Sat May 05, 2007 8:35 am
Location: Portugal
Contact:

Re: Something like Pengines in SWI Prolog

Post by Paulo Moura »

Prolog systems map a thread to a POSIX thread (or a POSIX thread emulation on Windows operating-systems). These are sometimes referred to as "heavy" threads. I'm not really familiar with Erlang but my understanding is that Erlang threads, sometimes called "green" threads, are much more light-weight and there isn't any 1-to-1 mapping to operating-system threads.

For a materialization of "Erlang in Prolog", you may want to look into WebProlog. See:

https://github.com/Web-Prolog
Paulo Moura
Logtalk developer

Post Reply