5 ms·
Huh, is SWI Prolog having a moment? I had always heard of Prolog as being obscure and overly academic. It's popped up a little bit recently however - the last
by padraic7a 7y ago
Huh, is SWI Prolog having a moment?
I had always heard of Prolog as being obscure and overly academic. It's popped up a little bit recently however - the last place I heard of it in use is in the recently launched TerminusDB https://github.com/terminusdb?language=prolog https://github.com/terminusdb?language=prolog
- pgtan 7y agoProlog gives you backtracking for free and liberates you from loops and if's.
- antoineMoPa 7y agoAt the price of a couple of headaches. Most programmers need to reverse the way they were thinking about programming when learning Prolog.
- Jtsummers 7y agoWhich is probably a good thing. Learning only one or two modes of thinking is severely handicapping.
- colanderman 7y agoBacktracking and unification (logic variables). The latter builds on the former and is key to some of Prolog's amazing capabilities.
- OskarS 7y agoProlog does have that reputation, but it's undeserved. It's incredibly fun to both learn and develop in, and it's very enlightening to learn this alternate model of computation. Prolog is awesome.
- nuncanada 7y agoNo. It is not... The CUT operator is worse than Ruby's monkey patching for debugging and maintenance reasons... Prolog without CUT is awesome, but currently there is no way to have reasonable performance without it.
- tom_mellior 7y agoYou can very often rewrite uses of the cut like: foo(X, Y) :- some_condition(X), !, bar(Y, X). foo(X, Y) :- baz(X, Y). to: foo(X, Y) :- ( some_condition(X) -> bar(Y, X) ; baz(X, Y) ). and get the same performance and clearer code. There are really very few actually useful uses of the cut in modern Prolog code. But we have no good, free, current teaching materials, so people get stuck learning the old ugly and convoluted ways.
- superdisk 7y agoThe arrow uses a cut internally which renders it nonlogical and ruins any benefit you'd get from even writing Prolog. At that point you're just using Prolog as a quirky imperative language. Unfortunately since it's almost impossible to model ideas without stuff like the arrow, cut, or \+ (not) operators, writing actual pure logical Prolog programs that actually do interesting things is supremely difficult.
- gmfawcett 7y agoSo the arrow doesn't represent logical implication? As a non-native, I would have read that as a clause that always resolves to `baz(X, Y)` unless the implication holds (i.e., `some_condition(X)` is true). Isn't that logically consistent?
- triska 7y agoIn general, using any of the mentioned predicates (->)/2, (\+)/1 or !/0 in Prolog code destroys essential properties we expect from classical logic, and therefore complicates declarative reasoning about the code to such an extent that it can be said to prevent it entirely. For example, both versions of foo/2 that are shown above suffer from the same core deficiency: If some_condition/1 has multiple solutions, then they are cut away and not generated at all. Therefore, for the most general query, ?- foo(X, Y). only a single answer, or a proper subset of all answers one would expect when reading (->)/2 as "implies", may be shown where, under a declarative reading based on first-order logic, there ought to be more. This is problematic because if any concrete solution S is cut off due to this deficiency, we can still force the Prolog system to yield it with: ?- X = S, foo(X, Y). So, we are in the situation that adding a constraint (X = S) yields a solution that is not shown when the constraint is removed. In other words, a specialized version of the predicate is more general than the original definition. This violates monotonicity, which is an essential property of classical first-order logic, and the basis for declarative debugging approaches that let us reason about the location of mistakes in Prolog predicates. To write good declarative Prolog code that is also efficient, we first need to find and implement the mechanisms that let us express predicates like foo/2 in such a way that they are efficient while retaining their generality as logical relations. One important building block pertaining to this concrete example was recently found with the new language construct if_/3, described in Indexing dif/2 by Ulrich Neumerkel and Stefan Kral: https://arxiv.org/abs/1607.01590 https://arxiv.org/abs/1607.01590 With if_/3, we can write foo/2 as: foo(X, Y) :- if_(some_condition(X), bar(Y, X) baz(X, Y)). The only requirement for this to work is to have a reified version of some_condition/1, in such a way that we can tell, from the implicit second argument, whether the condition holds or not, while still generating all answers for the most general query. Some predicates are already reified in the library, so we can write for example: ?- X = a, if_(X = a, Y = b, Y = c). X = a, Y = b. which succeeds without leaving choice-points, and that is good for performance. At the same time, we get both answers (X = a and also dif(X, a), i.e., X is not equal to a) on backtracking if we omit the first goal: ?- if_(X = a, Y = b, Y = c). X = a, Y = b ; Y = c, dif(X, a). Hence, the predicate retains important logical properties we expect from first-order logic, and this allows declarative reading and debugging based on these properties. To benefit from the true power of Prolog, such constructs must become available in Prolog implementations. For example, currently, the only Prolog system that ships with if_/3 as a built-in feature is Mark Thom's Scryer Prolog, where if_/3 and related predicates are available in library(reif): https://github.com/mthom/scryer-prolog https://github.com/mthom/scryer-prolog https://github.com/mthom/scryer-prolog/blob/master/src/prolog/lib/reif.pl https://github.com/mthom/scryer-prolog/blob/master/src/prolo... Other features that are necessary to make Prolog programs more declarative include CLP(ℤ) constraints, pure I/O, efficient implementation of partial strings as lists of characters etc., all of which are currently work in progress and as of yet only partially available in some Prolog systems. Over time, such features will become more widely available, and then they can be more easily taught and used to obtain Prolog programs that are pure and efficient.
- Mathnerd314 7y agoIt doesn't particularly look like it's having a moment: https://trends.google.com/trends/explore/TIMESERIES/1572366600?hl=en-US&tz=360&date=today+5-y&q=%2Fm%2F05vpz,%2Fm%2F03j_q,%2Fm%2F0dsbpg6&sni=3 https://trends.google.com/trends/explore/TIMESERIES/15723666... Both Haskell and Prolog seem to run on a school-year cycle where search interest peaks a little before the end of the semester. Prolog's cycle is significantly more pronounced, suggesting the interest is indeed purely academic. Whereas Rust has been growing steadily and shows little seasonality. I'd say it's random chance, given X million programmers and Y million articles there's always somebody who will see a lot of Z topic. Terminus in particular seems to be an extension of work Gavin did during his postdoc, in particular the Dacura stuff mentioned here: http://aligned-project.eu/open-source-tools/ http://aligned-project.eu/open-source-tools/. He deleted the DQS repository for some reason but there's a mirror here: https://github.com/bozicb/dacura-1 https://github.com/bozicb/dacura-1.
- xvilka 7y agoInteresting, from Google trends, it seems that Haskell is very popular in China, compared to other regions. I wonder what can be the reason for this.
- Guthur 7y agoCompetitive advantage. By inflating the search results they'll encourage the competition to spend inordinate amounts of time learning cat theory and trying to get the compiler to understand their code. In the mean time they'll hack it together in Perl. Sorry for the inappropriate about at humour, I couldn't resist.
- gtycomb 7y agoConsider that fact that prime-minister of Singapore knows Haskell by now http://wadler.blogspot.com/2015/04/prime-minister-of-singapore-plans-to.html http://wadler.blogspot.com/2015/04/prime-minister-of-singapo... He is already quite good with C++ https://arstechnica.com/information-technology/2015/05/prime-minister-of-singapore-shares-his-c-code-for-sudoku-solver/ https://arstechnica.com/information-technology/2015/05/prime...
- 7thaccount 7y agoI saw the TerminusDB posts on the Prolog subreddit and some of their Medium posts, but don't understand it or how they can make money.
- LukeEF 7y agoWe are pushing out documentation (worked examples etc.) as fast as we can so hopefully it will be come more understandable. In terms of making money, we'll launch a hosted platform in the near future.
- 7thaccount 7y agoThanks! It does like look interesting. Somehow a combination of graph database and prolog? I'm trying to think what kind of customers you're looking for. Medical research? I know things like Prolog are common there for ontologies (think I said that right).
- LukeEF 7y agoYes - a graph database implemented in Prolog and Rust (the storage layer - better for nitty-gritty bit manipulation). We think it's a great general purpose DB with all sorts of interesting features. Cool stuff coming on the platform, so keep an eye out!
- 7thaccount 7y agoI'll meet an eye out! Thanks btw!
- LukeEF 7y agoSWI Prolog deserves a moment as it is amazing. Terminus uses it not because of some ideological position but as it is the best technology for the job.