Ask HN: Why isn't logic programming more popular?
It seems like such a powerful paradigm, but it doesn't get nearly the press these days that OO and functional programming have. What could be the reason for this?
I wonder if we're due for a young language to rejuvenate Prolog the way Clojure has done for Lisp.
5 comments
[ 3.1 ms ] story [ 26.2 ms ] threadWhile it is a much different language now, Erlang was originally based on Prolog, and has been adopted, modified and extended to be a much better "realworld" language.
On top of that, from what I recall, it's pretty easy to have the backtracking to stumble into an infinite loop. As leaky abstractions go, that's pretty severe, probably enough to make people question the abstraction's usefulness.
Sloppy programming can lead to lots of unnecessary backtracking, of course, but some of the main benefits of Prolog come in using it for problems where you would have otherwise written your own ad-hoc backtracking search process to find a solution. That is, good Prolog code only likely to be slow because of it's backtracking when an imperative solution would have been slower/buggier.
Runtime slowness because Prolog is a dynamically-typed language that also strongly encourages the development of meta-intepreters as a common tactic is a separate issue. Often times a slower run time is acceptable in exchange for a much faster development time with the use of custom metalanguages (DSLs).
Integrated search aside, another benefit of logic programming comes in declarative knowledge representation. In an expression optimizer I wrote, it was easy to concisely define several code substitution patterns as simple logical statements and then create the overall optimizer as an interpreter over those declared patterns.
For problems that don't really revolve around search or knowledge representation (i.e. most CRUD web stuff), Prolog doesn't provide practical benefits. Nonetheless, understanding the otherwise foreign concepts of the language can give you the seeds of new design patterns and idioms for your familiar languages.
* http://vanemden.wordpress.com/2010/08/21/who-killed-prolog/ - Discusses how closely Prolog became tied to the rise and fall of the Japanese Fifth-Generation Computer Systems project
* http://vanemden.wordpress.com/2010/08/31/the-fatal-choice/ - Argues that Prolog was wrong-footed by the increased focus in industry on data structures and interfaces, rather than program logic. Prolog proposes a better way of doing program logic, but has little to say about data structures or encapsulation. (The article proposes how that might be fixed, too.)
* http://synthese.wordpress.com/2010/08/21/prologs-death/ - Argues that the difficulty of debugging and reasoning about Prolog execution, and its slow execution (especially in the early days), are bigger factors than many Prolog advocates admit.
* http://www.kmjn.org/notes/prolog_lost_steam.html - Argues that Prolog's low-hanging fruit got poached. In the 1970s it was the only real declarative-programming game in town, but over the next few decades a bunch of more specialized declarative languages succeeded in various niches, reducing Prolog's uniqueness and appeal.