Sign up ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

From what I've seen of Prolog, it seems as if it would be ideal for crafting a rule engine for an app. Yet, I don't believe I've ever seen a rule engine written in Prolog. Is there some inherent limitation in Prolog (e. g. poor garbage collection algorithm) that would prevent it from being used to build a rule engine?

share|improve this question

closed as primarily opinion-based by Dynamic, Graham Lee, pdr, mattnz, gnat Jul 18 '13 at 0:30

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise.If this question can be reworded to fit the rules in the help center, please edit the question.

The ladder. (almost) no one knows prolog, and even more devs don't want to know anything that doesn't get their daily work done so they can go home. Unfortunate, Prolog's pretty cool. – Jimmy Hoffa Jul 16 '13 at 17:46
Prolog makes a great edsl though. Embedding prolog in a language like Haskell or Scheme is the approach I usually take – jozefg Jul 16 '13 at 18:00
@JimmyHoffa That's diminishing. Some peoople learn prolog and then try to proactively forget it for the rest of their working life. – ZJR Jul 16 '13 at 18:05
I see 3 close votes--anyone care to tell me what's wrong with the question so I might fix it or withdraw it? – Onorio Catenacci Jul 16 '13 at 18:21
I voted to close as "primarily opinion-based." If you can convince me otherwise, I'll retract my close vote. I personally found Prolog to be opaque; I would expect a rules engine to have a more intuitive syntax for defining rules. And it is a programming language, not a syntax prototype for a rules engine per se. – Robert Harvey Jul 16 '13 at 18:29

3 Answers 3

up vote 7 down vote accepted

Rules engines in their infancy were written almost exclusively in Prolog--it was the logical language. For a small set of rules they worked great. However, it turned out they didn't scale very well. I don't have a definitive reference, but my understanding is that the way Prolog handles the chaining of rules is inefficient--the recursive model made for creating very large stacks that brought it to a crawl.

The development of the RETE algorithm and its successors allowed for a more efficient way to process large quantities of rules, and so took over.

Perhaps modern prolog would be more efficient than back in the 80's, when most of the early work was done.

share|improve this answer
See also:… – Matthew Flynn Jul 20 '13 at 3:15
Another article dealing with this:… – Matthew Flynn Apr 9 at 16:34

Tongue-in-cheek answer: because if the creators of Rules Engines knew about Prolog (or Mercury or PLANNER or …) they wouldn't be writing Rules Engines, they'd be using Prolog.

share|improve this answer

Generally, the point of a rules engine is that it is a part of another application. It is rather rare to see applications written in Prolog, and there isn't a commonly available interface to connect Prolog to applications written in other languages.

One rule-based tool for rule engines, that is written to be added to other applications, is CLIPS. CLIPS was based on OPS5 and uses the Rete algorithm for pruning rules.

share|improve this answer
not entirely true, there are some interfaces from external programs to Prolog code. SWI-Prolog has a C++ interface and a way to connect to R. – omouse Jul 16 '13 at 22:20
Actually all prolog engines I've seen work with C or C++ as "nobody" uses Proolog for complete apps, but "everybody" ahs ways to call C functions to call specialized libs. i.e. GNU Prolog – johannes Jul 16 '13 at 22:58
Thanks for that pointer @johannes. I was unaware of GNU Prolog at all; much less the fact that it can be called from C. – Onorio Catenacci Jul 17 '13 at 0:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.