3 ms·
I have been thinking of Prolog as SQL, but the “goals” are your data generator/table and the constraints are everything in there WHERE-clause. Made it simpler t
by punnerud 7y ago
I have been thinking of Prolog as SQL, but the “goals” are your data generator/table and the constraints are everything in there WHERE-clause.
Made it simpler to reason about.
Learning Erlang was also easier when I figured out that it is (was?) build on Prolog, with its analogy to SQL.
- FreeFull 7y agoThere is a subset of Prolog called Datalog, explicitly designed for use in databases. Datalog queries are guaranteed to terminate, and unlike Prolog it is fully declarative (order of declarations doesn't matter).
- slifin 7y agoDatalog is implemented in many Clojure(Script) databases if you'd like to try it out, Datahike is my favourite for dev/learning use but Crux, Datomic, Datascript and others exist
- felixyz 7y agoI think it's very useful to think of Prolog more as a simple database with a very powerful query language, for people who are already familiar with some programming languages and SQL databases. It's a better angle to come at it and understand the unique properties of Logic Programming.
- felixyz 7y agoRegarding Erlang, yes early versions were implemented on top of Prolog and the heritage is there for sure. Joe Armstrong talked fondly about Prolog in later years as well. For example, he described Elixir’s beloved pipe operator like this: > This is the recessive monadic gene of Prolog. The gene was dominant in Prolog, recessive in Erlang (son-of-prolog) but re-emerged in Elixir (son-of-son-of-prolog). (He was referring to so-called definite clause grammars (DCG) in Prolog.)
- Gene_Parmesan 7y agoIn terms of Erlang, my understanding is it began life as a modified Prolog, implemented in Prolog, around '86. But by the end of the decade Joe had created JAM, Joe's Abstract Machine, with others writing a runtime in C and the libraries. Nowadays Erlang runs on BEAM, which has since been improved and heavily optimized.