Prolog web programming
Asked Answered
C

6

19

At work, there was a discussion of using prolog as the backend for a rules engine on a web-app.

How would this get tied into existing systems?

Are there available prolog libraries for other languages allowing the invocation of prolog modules?

Coriolanus answered 24/9, 2010 at 21:7 Comment(1)
Just out of curiosity: How many guys at your workplace are actually well grounded in Prolog? It seems an interesting choice, business-wise.Darla
R
13

For SWI-Prolog, you could look to Thea2 which has support for SWRL in Prolog and can also be attached to external reasoners via JPL such as HermiT for OWL/SWRL reasoning, or Pellet, etc.

On a personal note, I have used JPL several times in the past to enable web-apps with a SWI-Prolog backend, which works just fine if you intend to program your web app using a language which is executable on a JVM, like Java, Groovy, or Scala, for example. Another alternative would be to hook SWI-Prolog into a C or C++ environment, which I haven't tried for a web-app.

If your web-app is using another development language that doesn't run on a JVM or in C/C++, then this mightn't be the right path for you as it seems to be a bit harder to connect a running SWI-Prolog environment to other language environments. However, that said, we have successfully implemented a SWI-Prolog-to-anything bridge using HTTP before, but this is less than ideal if performance is a necessity.

Reactive answered 24/9, 2010 at 23:58 Comment(0)
C
8

swi-prolog has a perfectly reasonable HTTP server/ web framework included.

You could talk to it over HTTP.

There are tools for parsing XML/SGML and JSON, and ODBC

Carilla answered 6/9, 2012 at 5:23 Comment(1)
JSON and as well as some DB connectivity, seems to be important for web. Unfortunately this is not listed here: en.wikipedia.org/wiki/…Gar
O
7

I'm not sure exactly what you're looking for, but you may want to look into Yield Prolog , which allows the embedding of Prolog code into programs using Python, C#, or Javascript. There is no API involved. I haven't used this myself (yet), but it may be amenable to what you're trying to do.

Olid answered 25/9, 2010 at 0:13 Comment(2)
In my understanding Yield Prolog is JavaScript based or so, would you run it on the web server? But for frontend integration I guess this would be great.Gar
With server-side programming exclusively in Javascript becoming more popular with node.js, this could be a useful tool for integrating Prolog processing on either the client or server side.Reactive
G
5

I guess an important prerequisite for web embedding, especially on the server side, is multi theading capability of the Prolog system. At least you would probably need this, if you want to serve multiple users concurrently.

You can then opt either for a pure solution, where the pages are generated and maintained by Prolog itself. Or maybe for a mix solution, where the Prolog system is only used for some business logic and another programming language is used for presentation and/or storage.

The following Wiki comparison table gives an overview of Prolog systems and whether they are multi threaded and/or support some web programming:

Comparison of Prolog implementations,
Operating system and Web-related features

For my own take on this problem I have set up a little tutorial that shows the use of the Jekejeke Runtime for server side business logic. Jekejeke Runtime is quite flexible, you can not only have multiple threads, you can also have multiple knowledge bases.

Jekejeke Runtime,
Deployment Methods

The Jekejeke Runtime is for example currently used in a productive sales system, by some custom read/write locks, it allows even remote hot swap of the knowledge base by an administrator without restarting the web context. Unfortunately there is no report yet on that.

Bye

Gar answered 6/9, 2012 at 9:55 Comment(2)
The SWI-Prolog web framework is multi-threaded. I've used it for an application where I was serving 10^7 or so requests a day.Carilla
Yes, thats also why SWI-Prolog is listed in the Wiki table link I gave in my post. This same Wiki comparison table has a column "multi-threaded" and also web-related columns.Gar
M
3

LPA Prolog has been widely used in various commercial web-based applications, most noticeably within Business Integrity's industry-lead document assembly product, DealBuilder

LPA provide various architectures for deliverying web-based applications - some of which are shocased within the VisiRule section on the LPA web-site www.lpa.co.uk

Clive

Mohawk answered 27/9, 2010 at 15:44 Comment(0)
T
3

Some languages make use of a bridge and provide a library for it for example in Python there's PySWIP for single-threaded use, so it doesn't play nicely with web apps. I've found Pengines to be far more versatile.

Pengines are in SWI, they're a way of querying Prolog via HTTP. There's at least a JavaScript, Java, and Python library to interface with them, but it's just a bunch of HTTP requests. Makes it easy to distribute, use as a micro-service, or horizontally scale. Although as anniepoo has witnessed to, a SWI server can handle decent amount of traffic!

Also in the case of JavaScript there's Tau Prolog which compiles to and works within JavaScript.

There's a lot of sense in using a logic language as a rule engine.

Tenth answered 20/4, 2020 at 16:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.