Hacker Newsnew | comments | ask | jobs | submitlogin
Ask HN: Anyone use Prolog?
10 points by bendmorris 1253 days ago | comments
I'm working through "Seven Languages in Seven Weeks" (http://www.pragprog.com/titles/btlang/seven-languages-in-seven-weeks). The inclusion of Prolog seems strange to me and I've heard very few examples of Prolog being used in the real world. Has anyone here used Prolog in production, and if so:

1. What did you use it for?

2. What are your thoughts about the language? Why did you choose Prolog, and were you happy with it?

3. How does performance, development time, etc. compare to other languages?

m0nastic 1253 days ago | link

I'm somewhat ashamed to admit that once in a former life I was tasked with writing a program for a coworker who I absolutely hated as I was leaving. He was going to have to maintain the program, and he wasn't really a programmer (contrary to what he said on his resume).

In a fit of juvenile rage, I wrote it in Prolog, even though it really wasn't particularly well-suited to being expressed that way. Apparently rather than tell anyone that he didn't understand how it worked (in spite of my fairly good documentation), he just pretended to be updating it for a couple years after I left.

Eventually the ruse was discovered, and they got rid of him.

I've been carrying that load around for the past twelve years, it feels nice to share it.


ScottBurson 1253 days ago | link

I used it a few years ago to write a reference implementation for a language feature whose real implementation was greatly complicated by the fact that it had to work in real time. I used Prolog to generate many thousands of test cases along with the correct result for each, then ran these through the real implementation to see how the results compared.

Prolog is not really a general-purpose language, so asking how it compares in "performance, development time, etc." is rather missing the point. If you have a problem for which Prolog is suitable, it will be easily the fastest way to solve the problem. But I wouldn't build a Web app in Prolog.

I'm afraid the only way to really get a feel for what it's good for is to write some programs in it. But it's a good tool to have in your toolkit.


lylejohnson 1253 days ago | link

We've used an Java-embeddable Prolog engine called tuProlog to provide the reasoning capability in several applications.

It's a very nice little language for rule processing, and it has served our needs well. It is unlike most other programming languages in that it's declarative as opposed to procedural, and that can take some getting used to. Our primary motivations for choosing it at the time were that (1) it was a "rules" language with which we were already familiar and (2) its license permitted its use in commercial software (unlike Jess, which was another contender).

As ScottBurson has already noted elsewhere in this thread, it's not exactly a general purpose programming language. We for example used it as just one component of larger Java-based applications. Its performance, at least for the implementation that we chose, is not great, but there's a performance-flexibility tradeoff: if the alternative is to write-up a bunch of nested if-then statements in Java, and to have to recompile that every time the rules change, I believe that Prolog comes out ahead in terms of development time.


kylecordes 1253 days ago | link

I used it a while back, to add some functionality that would have otherwise required a lot more code and work.

Story (and a little video) here:



silentbicycle 1251 days ago | link

Prolog is not a general purpose language, it's more like a database query language. Many common tasks would be painful in Prolog (it's really awkward for procedural code), but for rule-based systems, parsing, constraint satisfaction problems, prototyping interpreters, etc., it's an outstanding tool.


lamby 1253 days ago | link

Never used in production, just cannot see how it would work.

Use it for random puzzles like http://chris-lamb.co.uk/2010/07/24/four-men-mine/ though


Ernestas 1253 days ago | link

College. Lecturer said that in US they teach LISP and in europe Prolog. Edit: AI lecture.


sireat 1253 days ago | link

Used it at the university, liked the idea of the language, but implementation was sadly lacking. Not an easy language to debug.

I haven't read that particular book, but I imagine Prolog was included because it being a declarative language fits a paradigm of its own.


Lists | RSS | Bookmarklet | Guidelines | FAQ | DMCA | News News | Feature Requests | Bugs | Y Combinator | Apply | Library