Prolog integration into other environments

I use Prolog for an academic project. I wanted to know if there is a way for Prolog to interact with other programming languages. I want a simple redirection of input / output of questions and answers in Prolog.

I know that Prolog can call C functions in some implementations of Prolog. i.e. SWI Prolog.

I need a simple Prolog input / output redirection and the answer that the user provides.

Any help would be really appreciated.

+6
source share
4 answers

I do not see the true requirement for a foreign language interface for your task: use Prolog IO, it is easy to use and efficient. You can also start by supporting only protocol / 1. Just KISS advice ...

A foreign language interface is required if you need something implemented in this other language.

SWI-Prolog C ++ is an interface , it is much easier to use than a C-copy, and allows you to simultaneously expand the language using a very simple built-in encoding as an attachment of the engine to a stand-alone "main" one. And these 2 aspects can be gracefully cohexist: say, for a quick prototype, we only implement the built-in modules and use the upper level of REPL, while a full-scale application can start the engine, which will be used as a logical engine, and send it (hopefully tested through REPL) in the background.

Then there is a JPL for SWI-Prolog and Java. I don't know much about this ... I saw some of the problems that were reported on the SWI-Prolog mailing list due to the (mostly) complexity of the various thread models. But of course it works.

An interesting development is to provide an IDE in Eclipse ( PDT , Prolog development tools). I think they use their own Java interface. Currently, it may be a better choice than JPL.

But the most interesting SWI-Prolog interface can offer an HTTP server infrastructure today. If you know the development of a WEB client (HTML / JavaScript / XML / RDF), you have many tools for splitting your design into MVC Client / Server. Prolog launches the web service, and Rich Client interacts with the end user. This architecture makes your application ready to run locally as well as in the wild.

See How to ... This is not an easy task, but (IMHO) is very useful and long-lasting.

+6
source

SWI-Prolog can interact with C ( http://www.swi-prolog.org/pldoc/package/clib.html ), C ++ ( http://www.swi-prolog.org/pldoc/package/pl2cpp .html ), C # ( http://www.swi-prolog.org/contrib/CSharp.html ) and Python ( http://code.google.com/p/pyswip/ ). In addition, you can communicate with Prolog through, for example, external files.

+1
source

Take a look at Amzi Prolog + Logic Server - its goal is to make prolog programs available as components for other common languages.

+1
source

It depends on the Prolog distribution you are using. As noted earlier, SWI-Prolog provides various interfaces for the most common applications, such as C, C ++, databases, HTTP, XML and others. Distributing Ciao may also be useful for what you are looking for. In this case, this is C, so check out this link for Ciao Prolog and C

+1
source

Source: https://habr.com/ru/post/915983/


All Articles