Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prolog vs Erlang (and other functional languages) [closed]

What's wrong with Prolog?

Prolog is quite good with lists and pattern matching, and offers backtracking as a bonus. And yet for decades it remains a language apart, while functional languages blossom and multiply.

Take Erlang as an example. Its syntax is borrowed from Prolog, it's been initially implemented with Prolog, which is really interesting. That is, from Erlang people's standpoint, there's something fundamentally wrong with Prolog, or they'd have adapted Prolog to their needs.

like image 821
Alexey Orlov Avatar asked Feb 27 '16 10:02

Alexey Orlov


2 Answers

In my view, Prolog is now starting to become interesting, and the jury is still out on this question.

Yes, Prolog has a much longer tradition than Erlang. And it is also a much more complex language from an implementation point of view! It is also a lot harder to teach, exacerbated for example by the fact that tasks which would already be unsolvable for beginners in all other languages are traditionally given as the first few examples to Prolog beginners.

Getting backtracking, garbage collection, aliasing, attributed variables, constraints, exception handling and many other things that Prolog gives you right and efficient while honoring their often quite subtle interdependence is something that understandably cannot be accomplished within just a few decades, even if some of the most talented and educated programmers participate. Many Prolog systems that are currently available are just now reaching the point where you can seriously use them in production environments.

It is comparatively easy to make a dumbed down version of Prolog efficient and correct. Not so much for the real thing.

For comparison, take any serious program and see how long its implementation has taken. Most interesting programs are still under serious development even decades after their initial release. Same with Prolog, and a full-fledged Prolog system certainly gives you a lot more than many other language implementations.

And we do want the real thing! So, yes, there is something wrong with Prolog: It is hard to implement right. But there is much more that is very right with Prolog, resulting from the multitude of the features mentioned above: Once it is fully implemented, Prolog is an amazing and unparalleled development environment for all kinds of tasks, from theorem proving to web hosting, solving combinatorial optimization problem, test case generation and many other applications that are now arising.

For example, Erlang-style processes are just now being developed for Prolog. See for example Torbjörn Lager's Pengines.

Why is this only now (i.e., last 2 years or so) becoming available in Prolog? Quite simple: Many Prolog systems (in this case: SWI-Prolog) were not quite up to par to robustly run 24x7 web servers until recently. And why is that? Again, because it is hard to get this right for Prolog due to the subtle interdependence of its many advanced features. Slowly, we are at last getting there.

Prolog for the win!

like image 101
mat Avatar answered Oct 22 '22 00:10

mat


A language must must be able to sort real-life problems better than other languages to become mainstream. Speaking about Erlang, it would be nothing more than another functional languages if not its ability for soft real-time programming with preemptive multitasking able to handle millions of concurrent tasks. This plus its ability to run in a VM makes a truly powerful combination. In that sense those additions made Erlang unique. In fact, it's the only actor-oriented programming language widely used in the industry.

Look how many different dialects of C/C++ were created, and still C/C++ is in the mainstream. Those new dialects simply didn't give any advantage over what was already there (or not big enough anyway).

I am sure Prolog has its niche but it doesn't provide much over what other languages are able to deliver and the shortlist of problems on Wikipedia suggests some worth-pondering-over reasons as well.

like image 2
Greg Avatar answered Oct 21 '22 23:10

Greg