Integrating prolog into other environments
Asked Answered
B

4

7

I'm using Prolog for an academic project. I wanted to know if there is a way for Prolog to interact with other programming languages. What I want is an easy input/output redirection of Prolog question and answers.

I'm aware that Prolog can call C functions in some Prolog implementations. i.e. SWI Prolog.

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

Any help would be really appreciated.

Brendonbrenk answered 17/5, 2012 at 11:46 Comment(0)
R
7

I don't see any true requirement for a foreign language interface for your task: use Prolog IO, it's easy to use and efficient. You could also start with just support from protocol/1. Just a KISS advice...

A foreign language interface it's mandatory when you need something implemented in that other language.

SWI-Prolog C++ interface it's much easier to use than C counterpart, and allows both extending the language with really easy builtins' coding as well as embedding the engine in a standalone 'main'. And these 2 aspects can cohexist gracefully: say for a fast prototype just we implement the builtins, and use the REPL top level, while a full blown application can start the engine to be used as logic engine, and submit the (hopefully tested via REPL) queries in background.

Then there is JPL to interface SWI-Prolog and Java. I know little about it... I've seen some problem reported on the SWI-Prolog mailing list, due (mainly) to the complexity of different threading models. But certainly it's working.

An interesting development is occurring to make available the IDE into Eclipse (PDT, Prolog Development tools). I think they use their own Java interface. Currently could be a better choice than JPL.

But the most interesting interface SWI-Prolog can propose today it's the HTTP server infrastructure. If you known WEB client development (HTML/JavaScript/XML/RDF) you have plenty of tools to split your design in MVC Client/Server. Prolog runs a Web Service, and a Rich Client interacts with end user. This architecture make your application ready to run locally as well in the wild.

Please see the relevant How To section...Is not a simple task, but (IMHO) a very rewarding and long standing one.

Rowena answered 17/5, 2012 at 21:4 Comment(0)
E
2

SWI-Prolog can interface 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/). Furthermore, you can communicate with Prolog via e.g., external files.

Evannia answered 17/5, 2012 at 12:45 Comment(0)
S
1

Take a look at Amzi Prolog + Logic Server - its purpose is to make prolog programs accessible as componentto other conventional languages.

Singlet answered 17/5, 2012 at 16:40 Comment(0)
S
1

It depends on the Prolog distribution you are using. As previously commented SWI-Prolog provides different interfaces for the most common uses like C, C++, databases, HTTP, XML and others. The Ciao distribution can be also useful for what you are looking for. In this case is C so check out this link Ciao Prolog and C

Sphacelus answered 18/5, 2012 at 15:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.