Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Is Prolog worth learning?

  1. Jul 16, 2010 #1
    Is being able to work effectively with Prolog a worthwhile skill to have? Is Prolog widely used as far as logic programming languages go? Are there any others you might recommend? I am just interested in learning a new, different language after learning some C++ and learning Prolog (or a similar language) seems like a fun task.
  2. jcsd
  3. Jul 17, 2010 #2


    Staff: Mentor

    Others might disagree, but I don't see skills in Prolog programming as being especially useful. If it seems interesting to you, go for it, though, but if by "worthwhile" you mean something that would enhance your resume, I would advise learning more C++ or start with Java of C#.
  4. Jul 19, 2010 #3
    I used Prolog for a class in college, and that was it. Since then, I've only used Prolog in sentences where I talk about having used it once. As near as I can tell, it's pretty much never used in the general programming industry-- there are some niche jobs out there, but not much comparatively. If you find it interesting, go for it, but I wouldn't expect anything to come out of it from a professional standpoint.

    Depending on what you want to do, I'd maybe recommend Java, C#, PHP, Python, or Perl.

  5. Jul 19, 2010 #4


    User Avatar
    Science Advisor
    Homework Helper

    Pretty much unused in industry.
    But if you have a background in Prolog you might want to look at Haskell or F#, these are becoming more widely used but are tricky for people coming from a procedural or OO language to really get.
  6. Jul 20, 2010 #5
    I've had no experience in the industry yet but I can say Ive only seen one internship out of a ton where prolog experience was wanted, was at lockheed.
  7. Jul 20, 2010 #6
    If you end up designing robots, chatbots, facial recognition software, artificial intelligences playing go, then absolutely.

    If you end up doing anything that will reward with money rather than with publications in journals, probably not. Prolog is pretty much unlike most other languages though, yes, it's different than C, it's also just as different from Haskell or OCaml. The only way to learn prolog ... is to learn prolog.

    Learning prolog will greatly change the way you look at a problem though, that's for sure, if this is a good thing or a bad thing is in the eye of the beholder.
  8. Jul 20, 2010 #7

    D H

    User Avatar
    Staff Emeritus
    Science Advisor

    Prolog is a terrible choice for most of those applications. If you end up designing robots, (building toy robots in a university lab environment excluded), the robots most likely will have very little AI in them. Real robots, the ones used in factories, in the military, and in space, are dumb, dumb, dumb. Facial recognition is highly numerical. Whether you are using fast Fourier transforms, eigen decomposition, wavelets, or something new, Prolog is not the language for doing that. Computer go? That's done in procedural languages (C, C++), Lisp, and functional languages such as OCaml and Haskell.

    To the OP: Learning a computer language that teaches you to think differently is a good thing. However, that learning should also have some side effects such as gaining a marketable skill. Prolog has no side effects.
  9. Jul 21, 2010 #8
    I would beg to differ here, a mate of mine studied AI and had to do all those things and prolog at his studies was basically the holy grail, they did about all things in prolog.

    As for myself, for a lot of these problems I would immediately grab to prolog or nondeterministic Scheme which is very prolog like. He was the one who introduced me to prolog and I was pretty amazed how he could just code a reasonable AI to play a very good game of cards we always played in a couple of hours in prolog.

    The use of a functional language for go would be ... strange to me as there really is very little use for functions that have an co/domain of anything other than booleans for Go, either you move it there or you don't, either it's there or it is not.

    Essentially logical programming is functional programming where all your functions have a co/domain of booleans.

    http://homepage.mac.com/adammcnicol/A2podcast/COMP3_28_prolog.pdf [Broken]

    If you go to the last page, that little intro to prolog essentially gives a lot of these examples.
    Last edited by a moderator: May 4, 2017
  10. Jul 21, 2010 #9
    I used Prolog in college, too (I can't recall for what class). But when I went to the real world, poof! Gone. Did your friend wind up finding jobs (or landing any), that used Prolog? Or was his use limited to school? Just curious, since sometimes academia has a different skillset than the industry.

    I guess I kind of figure that SOMEONE out there is using Prolog, but I didn't think it was actually used in things like game AI for commercial products or anything. I can't imagine (for example) StarCraft 2's logic engine being programmed in Prolog. But I COULD imagine things like research projects for chess programs being written in it. Or maybe applications for neural networks? Again, I don't really see neural networks applied anywhere in business (maybe I'm just not looking in the right places), but I DO see them mentioned in research projects and such.

    For the record, I used Scheme for our AI class (not Prolog), and I have to say it was quite a different way of wrapping my head around problems than any language I had used prior (BASIC, C, C++, and Pascal at the time). I guess I don't remember much about what specifically makes it so much better for AI than other languages (or, so I've been told). Does it actually perform better? Or is it merely the way the language is constructed? At the time, I was rather unimpressed, and I recall always wishing I could write the assignments in C.

  11. Jul 21, 2010 #10
    Well, as I said before:

    If you end up doing anything that will reward with money rather than with publications in journals, probably not.

    I sincerely doubt it, there are maybe some jobs out there. But in the end, prolog was designed as a research language, not a commercial language. But then again, so was Fortran and C was originally designed as a portable assembly in mind and we saw what came from those.

    Edit: By the way, though he mostly programs in Java for his job, he does occasionally work in prolog, he works at a security firm and has actually convinced them to start using prolog for some things, apparently it went like 'This took several people a week do to in Java? I can do this in five hours in prolog.' - 'What is this "prolog" you speak of?' - 'Some language specifically designed for AI.' - 'You're on, I want to see this.'

    Unlikely that prolog would be used for game bots in shoot'em ups or RTS, but a chess bot or a go bot would have its applications.

    Prolog is ultimately best suited to code AI's that learn along the way.

    Well, prolog could indeed have an application in market analysis I reckon, predicting the next step the market will take and all those things with a self-learning AI, prolog is suitable I guess.

    Though, one thing I have to add is that I'm with Dijkstra on the fact that corporations make bad decisions regarding programming languages and technology in general, CEO's, usually don't know anything about programming and I am particularly unimpressed with the grave errors some CEO's can just make and still get a gigantic bonus. Dijkstra was ultimately right that what we're doing was and still is to some extend a time bomb. The code on which large corporations run is hacked together and isn't scalable at all. Declarative languages such as prolog or functional languages provide scalability.

    But that's all tangent to how easy you're going to find a job with prolog, that they should do it doesn't mean they do it. In the end we have to accept that large corporations started wrongly decades ago and have now become dependent on badly coded software in the wrong language which a rewrite in a good language would be an investment, but an expensive one.

    So my final verdict is simply to be summarized with:

    A: prolog will not land you a job in commercial ventures
    B: prolog has its uses in academics
    C: prolog will teach you a way to think that could be useful

    Prolog's performance used to be extremely bad, but JIT compilation and some tricks have since made prolog reasonably on par performance wise with other similar dynamic and reflective language, it's not a number cruncher though.

    Prolog isn't better for AI per se, prolog in the end is mainly for self-learning systems, for instance, the physics and facial expressions behind Final Fantasy, The Spirits Within were done in Scheme I believe, and Scheme is an excellent language for that. As soon as you start dealing with numbers instead of true/false, prolog isn't that good.

    Well, most Scheme / prolog / Haskell whatever programmers will tell you 'if wish to use assignments, you're doing something wrong' and I second this. So to the OP, you've only mastered prolog once you never think 'Hmm, it would be nice to change the value of this variable here'. Don't try to replicate an imperative style in a declarative language, rather realize that a declarative paradigm is simply different.

    And this is also one of the valuable skills that prolog will teach you, in prolog, you don't code while you think of the problem, in prolog and most declarative languages, you work in a top-down way. You first analyse exactly what your problem is, and then the code writes itself. This is why declarative programs are often very terse, but tend to require extensive planning before you can even begin. You have to ask yourself what the problem is precisely before you can solve it. Prolog thus teaches you to disassemble a problem into its essential components, which is a skill that could be useful outside of programming.

    So if you have the time, give it a try, see if you like it, and if not, then by all means stop. Because it probably won't land you a job, though it might look good on your resume that you also know prolog, it shows you can adapt.

    I mean, try to write a program that when given an arbitrary version of the liar paradox gives its solution space to you. You know, those riddles like 'Frank says that john always lies, Michelle never lies and says that at least one of frank and john lie ...', you do not want to do that in Java or C. You want to do that in prolog or maybe nondeterministic Scheme
    Last edited by a moderator: Jul 21, 2010
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook