4 ms·
Prolog is well worth learning for several reasons. One is practical and easy to explain: Syntactically, Prolog is a very simple language with a powerful implici
by zmonx 9y ago
Prolog is well worth learning for several reasons. One is practical and easy to explain: Syntactically, Prolog is a very simple language with a powerful implicit search mechanism. As one consequence, it lets you prototype ideas quickly, especially if search is involved in some way, which is almost always the case in practice.
The second reason is harder to explain. I can only hint at it for now, and you will understand the full extent once you apply Prolog in actual practice: With Prolog, you feel closer to the actual task. First, because you will not manage to even get started unless you manage to express your ideas clearly. Without this, there is nothing "to do" in Prolog. In other languages, it feels that you can always "do" something, such as declaring interfaces, types etc., even if it does not truly help you for the task at hand.
I have sometimes heard students proclaim: "Prolog is so hard! I could easily solve the task in Java, but I cannot solve it with Prolog." When you ask them to describe how they would solve the task in Java, they are unable to do it.
In my view, this shows that the tasks we demand from Prolog beginners are typically already inherently much harder than what we demand from beginners in most other languages. There is also a reason for this: These simpler tasks would often be non-issues or at most extremely trivial in Prolog, so we eschew them entirely.
Second, you are reasoning directly about terms, without any intermediaries such as pointers, references or even arrays. It's just terms, terms all the way down. They come into existence by simply writing them, or by stating the properties that ought to hold, and asking the system to find them. This second property is specific to logic programming and not present in functional languages.
In a very real sense, this is close to the ideal of programming: We describe what we want, and the machine finds it.
Prolog has many other advantages too, such as admitting very simple yet powerful meta-interpreters, much shorter ones than are possible for Lisp, for example. The implicit search mechanism and logical variables enable such features which are missing from most other programming languages.
Finally, constraint logic programming blends in naturally in Prolog. This is a very important paradigm that is heavily used in specialized industries, making excellent Prolog skills also very marketable.