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?

  • 7
    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
  • 3
    Prolog makes a great edsl though. Embedding prolog in a language like Haskell or Scheme is the approach I usually take – Daniel Gratzer Jul 16 '13 at 18:00
  • 3
    @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
  • 5
    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
  • 2
    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

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.

| improve this answer | |

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.

| 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.

| 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. – Old account Jul 16 '13 at 22:20
  • 3
    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 gprolog.univ-paris1.fr/manual/html_node/gprolog065.html – 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
  • Also see: swi-prolog.org – user48956 Jun 14 '19 at 18:37

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