Tell me more ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I learned Prolog many years ago in University. During my professional life, I have never needed to use Prolog. Have I missed something special?

As far as I remember Prolog requires completely different mindset comparing to prominent programming languages.

Is Prolog really ever used to implement something professionally useful?

share|improve this question
2  
Prolog (and poplog) are very good for AI coding. If you're not doing AI related things professionally/seriously, you may not use it at all. Like how a non-engineer may never use MATLAB seriously. – glasnt Feb 23 '11 at 23:14
Good question. Prolog is the first programming language taught in computational linguistics at Uni Potsdam, but after that we don't really use it that much, even if we're quite good at it. It's a pity. Every time I see a question such as "How do I use an accumulator" or "How do I get all possible answers" on StackOverflow, it makes me wonder where the actual professional users are – most stuff seems like homework. Or maybe Prolog proficiency turns you into a robot who never has questions. – Felix Dombek Mar 11 '11 at 2:28
I once heard of a system for fault detection written in Prolog and implemented somewhere in Austria (Klagenfurt?) According to what was told to me, the product was quite good and being sold to customers. If you consider this "professionally useful" then the answer is "yes". – Giorgio Jan 14 at 9:10

9 Answers

up vote 10 down vote accepted

In my view, learning the basics of Prolog is very worthwhile, irrespective of whether you'll ever use it in the real world. It's also very worthwhile to understand the basic ideas underlying unification, and how a (trivial and inefficient) implementation might be handled.

If you have a problem that would be best solved using declarative logic, you should ideally recognise that and know (if you have the choice) to use the right tools for that job.

However, I agree that Prolog needs a very different mindset from conventional imperative languages, and also a very different mindset from functional languages. Beyond a certain point, it appears to require a lot of experience (just as with anything), and there's even a lot of "textbook" knowledge that makes my brain dribble out of my ears.

My impression is... we are probably both missing something special to a degree, but it wouldn't be practical to dedicate the time to learning even a reasonably complete textbook-level knowledge for Prolog, let alone trying to develop real-world experience, unless you're considering a possible logic programming career.

I've recently been reading a book on AI and expert systems published in 1989 - a lucky find in a second hand bookshop. In significant part, it's a specialised tutorial on Lisp and Prolog. True, most of what it covers hasn't been that impressive for quite a while (search, heuristics etc), but it's still very interesting, and IMO a worthwhile thing to invest a bit of time in.

More recent books that specifically describe Prolog would be better for learning the language, but the risk then is that your brain will dribble out of your ears somewhere in the intermediate-to-advanced material.

share|improve this answer
AI/prolog newbie here. Any online resources you'd recommend? – yati sagade Sep 14 '11 at 19:30
@yati - Try amzi.com/AdventureInProlog/advtop.php - I once ran through a tutorial on the Amzi site which seemed OK as far as I remember, but that was a very long time ago. All I've looked at recently (probably the last 5 years) for Prolog is that AI book I mentioned in this answer. You should search for/ask a question here rather than posting comments, especially comments added to answers written by someone who's basically a long-term newbie anyway. Prolog's something I look at rarely and in very little depth - or else I'd have stopped being a newbie a decade or more ago. – Steve314 Sep 14 '11 at 22:28

This wasn't me, but assuming the question could be "did anyone implement something serious with prolog?" this might count:

http://asmarterplanet.com/blog/2011/02/the-watson-research-team-answers-your-questions.html

Watson is powered by 10 racks of IBM Power 750 servers running Linux, and uses 15 terabytes of RAM, 2,880 processor cores and is capable of operating at 80 teraflops. Watson was written in mostly Java but also significant chunks of code are written C++ and Prolog, all components are deployed and integrated using UIMA.

share|improve this answer

I know A.I. programmers use it.....because I did a Prolog course in my A.I. class but besides that I haven't seen much else said about it. here is a similar question with lotsa answers! http://stackoverflow.com/questions/130097/real-world-prolog-usage

share|improve this answer

Prolog is great for a fast prototyping. For example, in http://www.cri.ensmp.fr/classement/doc/A-381.pdf an SSA-transform for GCC is first implemented in Prolog, and then in C.

I am using Prolog inside compilers for a quick and dirty implementation of type systems, certain optimisations and semantic checks, and I rewrite that Prolog code into something imperative only if its performance is not acceptable.

share|improve this answer

You answered quite quickly, but I used Prolog in the mid-90s to design insurance rate calculators which would determine for us certain customer segments (read risk) that would fit within premium rates. It is something that you wouldn't necessarily see day-to-day, but surely has affected your P&C premiums over the years.

share|improve this answer

According to (This FAQ)1 Parts of Watson, the IBM machine that played Jeopardy, were written in prolog. (see question #6)

share|improve this answer

I have used Prolog professionally on a (significant) handful of occasions (diagnostic expert system; HTML transformation; set membership). I have a deep affection for the language so, yes, there's bias here but it's easy to be objective about when Prolog is (more/just as) suitable- you really need to be processing recursive structures; the best example I can give is a relational database table but there are countless other examples (it's probably easier to enumerate counter-examples such as random user input or (most) mathematical functions (however, many mathematical functions do have a recursive structure and hence are perfectly appropriate (discrete fast fourier transform, for example)).

But, of course, very few 'end-to-end systems' can be defined solely in terms of the processing of recursive structures, (exception: theorem proving- but this is a rather academic exercise*) so it's fortunate that a prolog process can be grafted on to a 'more standard imperative process' using all sorts of different techniques (it hardly matters what but a web-service interface is probably generally suitable); so you can deal with the UI, and random event processing etc and then hand-over when necessary (for doing complex database queries or any number of things you might want to do with your recursive structures). I find it works beautifully- better than, for example, LINQ.

So- grab your recursive structures by the sensitive bits and write some lovely, clean, elegant, maintainable Prolog! :)

PS when I'm not using Prolog, I fall back to C#

  • Although, I long for the day when, at least some aspects of, commercial programs are proved correct as a standard practice.
share|improve this answer

Try writing a sudoku solver in your favorite language, then check how it is done in Prolog. In general any CLP problem suits nice with a declarative language like Prolog.

It is also used extensively in formal verification of hardware and software (academically and probably professionally but I don't have any references to companies).

Finally, Erlang is deeply influenced by Prolog, with fault tolerance and concurrency in mind.

share|improve this answer

I have learned C++ many many years ago in University.. During my professional life, I really did not need to use C++. Did I miss something special?.. As far as I remember C++ requires completely different mindset comparing to prominent programming languages, like HTML.

Is C++ really ever used to implement something professionally useful?

share|improve this answer
Are you serius? BTW, HTML isn't a programming language. – KeyneON Aug 31 '11 at 18:52
@KeyneON: This is obviously sarcasm as he is restating the question just using different languages to illustrate the point. If all you do is web-design C++ is not a language you will bump into. If you do DB design and optimization you are unlikely to use HTML. If you work in AI you will probably not see VB etc. It is dependent on the sector you work in that will dictate the tools you use to solve the problems associated with that sector. PS Some people would consider HTML a language. It is a set of instructions that are interpreted to generate an output. Turning complete: No. Language: Yes. – Loki Astari Jan 13 at 23:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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