12

I have not yet heard about any uses of a logical programming language (such as Prolog) in the software industry, nor do I know of usage of it in hobby programming or open source projects. It (Prolog) is used as an academic language to some extent, though (why is it used in academia?).

This makes me wonder, why should you use logic programming, and why not? Why is it not getting any detectable industry usage?

Anto
  • 11,157
  • 13
  • 67
  • 103

3 Answers3

8

Outside of academia... I've heard of it used more in AI, sometimes in games (I heard it drove the AI in the Black & White series). I've also heard of variations used to run rules-engines for certain businesses and economic simulations.

My guesses for lack of widespread adoption are:

  • It's weird - most people aren't used to programming in it, and they can do what they need to in other languages.
  • Lack of vendor support - If Microsoft suddenly started pushing Prolog# (with the full weight of the .NET library and toolset and formal support behind it) as The Next Big Thing - and then IBM and Oracle came up with something to compete I bet you'd see it pick up!
  • Lack of integration - I don't know what libraries are available for Prolog - last I checked there wasn't much graphical or networking libraries, meaning that a Prolog "application" has to be wrapped in another application that interacts with the rest of the world.
FrustratedWithFormsDesigner
  • 46,105
  • 7
  • 126
  • 176
  • "a Prolog "application" has to be wrapped in another application that interacts with the rest of the world." That was actually a feature for us. We could more easily isolate the prolog bits because the interface to it was so simple. – S.Lott Mar 17 '11 at 17:57
  • @S.Lott: Ok, I can see that as possibly positive as well, though when I was in school and wanted to actually *make* an application with Prolog, I found the plumbing and wiring between the pieces to be a major challenge and obstacle. – FrustratedWithFormsDesigner Mar 17 '11 at 18:06
5

We used it to build parsers. It was easier to work with than lex/yacc.

Why is it not getting any detectable industry usage?

This is unanswerable. What does "detectable" mean? Who needs to get the detection memo?

http://www.meridiansystems.com/landing/ppc/prolog/getvideo.asp

Ask Meridian Software about their prolog offering if you want facts.

However, there are some barriers to entry that I've experienced.

First, prolog can be slow. When there are a lot of candidate rules and no simple cut operations to restrict the search space it can take a while to get something done.

Second, prolog isn't procedural or functional, so many programmers balk at using it. (Interestingly, some programmers balk at using SQL, too. For that matter, some programmers will reluctantly use SQL and do strange things like avoid join operations, or claim that COUNT(*) is magically inefficient.)

Third, prolog requires some pretty clear thinking on what the various cases are. Procedural programming can be sloppy and still work reliably. Non-executable statements are acceptable.

The following is acceptable in most circles.

b = a + 1
if a > b: # always False

This kind of murky thinking gets you in trouble in prolog.

S.Lott
  • 45,264
  • 6
  • 90
  • 154
2

One issue is that Prolog isn't really programming in first-order predicate logic, which is computationally intractable (I don't remember to what extent, but it's not in NP, and if you add arithmetic to it it's formally undecidable). Therefore, it's a simplification.

In logic, a proposition can be proved true, proved false, or not proven either way. Prolog has only proven and not proven, "not proven" typically meaning false. Moreover, the order of Prolog clauses can affect the execution, which is not the case for logical clauses. In the course I used it in, I started thinking of Prolog as a pattern-matching language more than a logical language.

Therefore, Prolog programming depends not so much on logical correctness as the Prolog language itself. It's a useful language in some ways, but it's nowhere near mainstream, and it hasn't had the tool and community benefits of a language like C++.

David Thornley
  • 20,238
  • 2
  • 55
  • 82