1. 19

  2. 4

    It’s an interesting idea to use prolog as a nosql database but it got me thinking about the reverse:

    What if we added some kind of support for schemas in prolog? perhaps special predicates that aren’t as expressive as full blown prolog predicates, which can be looked up more efficiently

    1. 8

      Some prolog implementation support what is known as tabling that is close to what you described: http://www.swi-prolog.org/pldoc/man?section=tabling. Mercury also has determinism modes that lets the programmer specify whether some predicates are deterministic and uses various optimizations to make their execution more efficient.

      Logic language implementors have thought about these problems but just like in databases there are no silver bullets and one needs domain expertise to model/encode the problem in a way that will take advantage of the language’s strengths. Overall I think there should be much more Prolog (and more generally logic languages) in the DevOps ecosystem. The characteristics of logic languages are almost custom made for expressing system level constraints and operations.

      1. 4

        Once upon a time there was prodog that was about exactly that. You are correct that there should be more Prolog in the DevOps area, but the people who implemented successful tools in the area, tools like Puppet, ansible, cfengine, terraform, etc where you define the end state but not the how, seem not to have been exposed to that way of thinking, whereas the Prolog crowd seemed more interested in Expert Systems and the like.

        Maybe Prolog could have been a good vehicle, but we did not have enough sysadmins in the 90s with Prolog experience to put to practice.

        You can see ideas for Prolog and system administation here

        The best thing one can hope for today, is a Prolog system that emits terraform, ansible and other descriptions.

        1. 1

          I think Prolog can be used to also enforce policies. Instead of implementing the policy using some bastardized YAML DSL we can use Prolog to specify properties of the infrastructure graph we want. If we also implement generating the terraform or ansible from the facts and relations then we can be sure we will never violate whatever invariant we were trying to enforce. That would be a nice future to live in.

          1. 2

            With regards to policies, there is the Event Calculus which has been used for such work (example). I tried to work with such stuff during my MSc, but not with much success. However I remember that Murray Shanahan has an Event Calculus implementation in Prolog and there exists one in Python

        2. 2

          I think XSB Prolog also did tabling.

      2. 3

        OWL ontology language used in “semantic web” allows to define prolog-like rules. There are lots of “reasoners”, engines for inferring RDF facts based on existing RDF facts, for example Apache Jena.

        Despite semantic web is almost dead, Wikidata largely uses semantic web technologies. For example, there’s SPARQL query interface for it. It’s also very prolog/datalog-like.

        1. 2

          Has this not been tried in the past with Active Databases and Rule Databases? Granted, there’s nothing wrong with bringing back old ideas, especially if the surrounding ecosystem can help better develop them.

          Pesonally, I’d try to implement a Prolog over JavaScript (I think there are a couple) and the see whether it can be used to query a MongoDB system.

          1. 3

            There’s datascript, however with datalog instead of “full” prolog. It even has examples of production software built on it.

            1. 1

              Wow! I used to be a datalog junkie back in the day. Thanks for the link

            2. 3

              I’m sure it has been tried. The idea is “obvious” enough if one is familiar with the logic paradigm. I’ve given up on trying to come up with original ideas when it comes to computing. Chances are someone 20 years ago tried the exact same thing I’m thinking of right now.