2 ms·
>> So...in my opinion it is a little bit like SQL. You would not use SQL to write an application (I hope!). Not a bad hunch, but SQL is in a way only half of P
by YeGoblynQueenne 10y ago
>> So...in my opinion it is a little bit like SQL. You would not use SQL to write an application (I hope!).
Not a bad hunch, but SQL is in a way only half of Prolog.
SQL relations (tables) can be seen as first-order logic predicates that are always true.
Prolog has those (they're called unit clauses, or "facts") but also has relations that are actually implications (called definite clauses, or "rules"). "Rules", being conditionally true (or not) allow programming logic to be described. [1] [2]
The funny thing is that in Prolog both facts and rules are the same kind of thing (a special kind of first-order predicate called a Horn clause). In, er, fact, so are the queries you write at the command line (negative clauses which are always false, so that you can prove them true by refutation, binding variables in the process; this is how you "retrieve data" in Prolog, where your program is your data).
In this sense Prolog is very different to SQL, which has a clunky syntax on top of a neat abstraction- in Prolog you program with the abstraction itself so, yes, totally: in Prolog you use the database to write an application. Except it's not a SQL databse.
[1] https://en.wikipedia.org/wiki/Horn_clause https://en.wikipedia.org/wiki/Horn_clause
[2] http://mathworld.wolfram.com/HornClause.html http://mathworld.wolfram.com/HornClause.html
- gavanwoolery 10y agoI agree - I did not clarify very well, but what I meant is that it is like SQL in that it is probably best utilized with an accompanying language. :)