Hacker News new | past | comments | ask | show | jobs | submit login

I'm not familiar with Prolog and this statement sounds insane. I'm not doubting you exactly, it's just not something I can concieve. Can you provide an example of a problem that would only take a few dozen lines of Prolog which would take several thousand lines in another, "normal", language?



It's been more than a decade since I worked in Prolog, so I cannot give you a direct example but can try to answer :)

Basically, Prolog is declarative programming. You can attach properties to your data and then define relations between the data based on whether they have that property (or not). Something along the lines of: X is grandfather of Y if X is man and X has child Z which has child Y.

The above statement is very simple to write, a couple of lines. This will perform depth first search (or breadth first with some longer algirithm) using your data. As a result, Prolog can provide all such matches of all your data, or just the grandchildren of X, or both grandfathers of Y, etc.

Anyway, what you are really getting is just a good implementation of the search through the relations based on constraints. The main reason Prolog is used is because other languages just don't provide a good library for constraint based search through your data.


So You are saying that there is really not much difference between prolog and lets say constraint solver written in Java (DSL on top of another language)? Because if this really true than now I understand why this language never caught on.


I think you should do more than read one 4 paragraph comment before you cement an opinion on anything


It depneds on the comment and the article. I actually had some contact with prolog (did a semester in university mamy years ago) and still up till today did not find a reason to use it on real life - mainly because I have responsibily to keep my solutions maintainable for decades and I do not see how could I keep easily find people willing to work on prolog and not switch obver to where reall money is at. So when I saw an interesting insight that somehow maches my very old intuition (that prolog is mainly constraint solver) I wanted to ask more. And I believe that reading this whole introduction could potentially not give me this insight.


Learning almost any DSL pays off, when the alternative is to macroexpand the same stuff in your head and write out eye-glazing boilerplate.


That seems like main reason any high level language exist - to give us abstraction layer with better building blocks to solve problems. The trick is to choose which DSL to use in project so its maintainable (and cost effective). I even long time ago learned some prolog (had a whole semester in university on it) but I cannot find a reason why I would use it anywhere in real projects.


Oh, well, Prolog is just a good DSL for a constraint solver. Usually written in C, but you can do it on Java too.

As I said, I have never seen one integrated with any language (oh, well, now I have seen Flix).


See Racklog in racket, that predates Flix by a long time.


> now I understand why this language never caught on

Can you illuminate why the language being a constraint solver tells you why it didn't catch on?


I believe in general purpose languages - from the business point of view its better to invest in one platform/language/ecosystem (if possible of course) than to spread too thin - each specialized language is potential liability (its trade-off but still the additional languages have to carry their own weight allowing for example to access more platforms)


Basically any problem involving a complex search of a solution space is a strong candidate for the above statement. There are specialized tools for doing that in other languages, but a) they specialize on a single optimization/search topic and b) their use is generally quite complex vs. prolog.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: