Live data from Hacker News

Learn Datalog Today

learndatalogtoday.org

51–56 of 56 posts

Re: Learn Datalog Today

#51
post #4

It's a shame that there doesn't seem to be any decent open-source implementation of Datalog. If you go for full Prolog instead of Datalog, there are several (Scryer Prolog being my personal favourite).

1. Datomic - While not open-source, it has an open-source version called Datomic Free, which is a distributed database designed to enable scalable, flexible, and intelligent data storage and queries. Datomic's query language is closely inspired by Datalog. 2. DataScript - An open-source in-memory database and query engine for Clojure, ClojureScript, and JavaScript that is heavily influenced by Datalog and Datomic. 3.…

Souffle deserves a high ranking. It really is a nice datalog. If only field reference was possible, instead of excessive tuple pattern matching. (Though, one could write a preprocessor for it, it is just syntax).

Differential datalog is also nice, if you have the usecase.

Re: Learn Datalog Today

#52

For the idiot in the thread, why would I use datalog (which I've never heard of before) over SQL? Having looked quickly at it just now it seems (Wikipedia article) similar to Web Ontology Language (OWL), though I believe datalog may have been around long before owl.

On a syntax level, parsing, generating, and templating datalog is _much_ simpler than doing the same to SQL. DBT would never exist if every SQL database accepted datalog queries and SQL injection attacks would be rare to non-existent. The more interesting answer is to think of datalog as making it easy to encode nearly all of your application logic as a bunch of self-referencing, incrementally updated, materialized v…

I can't really understand this without seeing the equivalent SQL as I don't understand datalog.

Is this SQL query similar to the first datalog query you listed? I apologize for how HN formatted the below and my lack of understanding for how to get around it.

Select u.name, u.email, u.id From Users u Join Cookies c on u.name = c.name

Re: Learn Datalog Today

#53
post #7
post #4

It's a shame that there doesn't seem to be any decent open-source implementation of Datalog. If you go for full Prolog instead of Datalog, there are several (Scryer Prolog being my personal favourite).

Here’s a blog post showing you how to roll your own in ~100 lines of JS https://www.instantdb.com/essays/datalogjs

Except that is not remotely Datalog.

Would folks please stop publishing nonsense about simple relational algebra implementations claiming they are Datalog, even though there is no recursion.

This is like seeing an article about how to implement context free parsing and finding one about implementing regular expressions with DFAs.

Re: Learn Datalog Today

#54

Earlier quoted context omitted.

On a syntax level, parsing, generating, and templating datalog is _much_ simpler than doing the same to SQL. DBT would never exist if every SQL database accepted datalog queries and SQL injection attacks would be rare to non-existent. The more interesting answer is to think of datalog as making it easy to encode nearly all of your application logic as a bunch of self-referencing, incrementally updated, materialized v…

I can't really understand this without seeing the equivalent SQL as I don't understand datalog. Is this SQL query similar to the first datalog query you listed? I apologize for how HN formatted the below and my lack of understanding for how to get around it. Select u.name, u.email, u.id From Users u Join Cookies c on u.name = c.name

Almost. What I wrote is more like:

  create view LoggedInUserView as
  select u.id as id, u.name as name, u.email as email
  from Users u
  join Cookies c on c.name = 'login' and u.id = c.payload->>'userId';
where payload is a json blob. (Indent code by 2+ spaces.)

Most people wouldn't design their schema in a SQL database like this with a bunch of special-use relations/views, but datalog encourages you to do so since defining a new relation is the only means of abstraction. In effect, you've created an API endpoint similar to /api/auth/users and, what's more, you can use the LoggedInUserView in other rules to define new relations.

Re: Learn Datalog Today

#55
One of the easiest to get started on Datalog in my opinion is really clingo https://potassco.org/clingo/ , which can be pip installed and has python bindings. Answer Set Programming goes beyond datalog, but it holds datalog semantics as a sublanguage. It is unfortunate this is not well advertised.

  pip install clingo

  #! clingo 
  edge(1,2).
  edge(2,3).
  path(X,Y) :- edge(X,Y).
  path(X,Z) :- edge(X,Y), path(Y,Z).

Datalog has some really cool use cases for program analysis (more or less relations represent an overapproximation of possible values variables can have). The declarative constrained nature of the language enables incrementalization, composition of analysis, and connection back to other formal aspects like types.

Souffle is very good, logica has a nice install story. https://colab.research.google.com/drive/1KJ6xKSwpw5FWWkvUOyB... . Many other interesting datalog systems.

- https://www.philipzucker.com/notes/Languages/datalog/

- https://www.philipzucker.com/notes/Logic/answer-set-programm...

Re: Learn Datalog Today

#56
post #22

Earlier quoted context omitted.

I'm sad their last commit was 2 years ago, seemed like a really cool idea

The authors spun it out into a startup, Feldera. A paper describing their idea also won Best Paper at VLDB 2023. The idea is very far from dead.

That's awesome
Post reply on HN