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.
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.
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.
Take a look at Amzi Prolog + Logic Server - its purpose is to make prolog programs accessible as componentto other conventional languages.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With