← Back to context

Comment by Vaslo

7 years ago

With due respect, Datalog is a very difficult language to learn, and it just doesn't have the support and resources SQL does. We were forced to use it in a Data Cleaning course a few years ago because the professor was big on it, and everyone struggled. To this day, fellow students complain about that part of the course. No one ever looked at it again after that class.

Datalog will ALWAYS be a niche language, because it is designed for a certain type of computational mind. The vast majority will want to learn SQL due to its ease despite any shortcomings it may have.

I am not familiar with Datalog but if it is anything like Prolog then it should be extremely easy compared to SQL. Right now if I want to make any query that is more complex than Select x from table in SQL I will have to make multiple google searches and look at multiple resources that explain the unintuitive SQL syntax. Meanwhile if I want to do something more complex in prolog it will be trivial. For example if I want to do an inner join in prolog I can just do something like: table1(X, FirstName, LastName), table2(OrderId, X, OrderDate, OrderCost).

I have heard nothing but good things about learndatalogtoday.com

Datalog suffers from some of the same problems that SQL does (different dialects). It does seem to me that Datomic and Datascript have the most intuitive syntax.

I think as a user if you have to think about the computational aspects of a query you're doing something wrong.

From a declarative sense datalog is much more concise than SQL. Depending on how you want to think about it, it also subsumes sparql.

The datalog compilers we're working on in our group create very efficient code and the evaluation strategy sometimes is far from what you would think of by looking at the query.

But since the result is defined as the minimal herbrandt model/fixpoint of the Tp operator you don't think about computation because you don't have to.

Is the difficulty you had due to it being a functional language? Or something more intrinsic to the language itself?

  • Much of it was writing code akin to recursive SQL (which was touted as one of the things it was way better than SQL at). Just never could understand it, and it took hours for most to get simple recursive models like connecting family trees. That language (like many) has a lot of work to do in terms of support and tutorials in order to build reasonable interest for it.

    • I think the problem here is is institutional--both our teaching institutions and normal industrial practices. Objective studies have shown repeatedly that functional programming models (which emphasize recursion, a stumbling block you mention) are easier for students with no prior programming knowledge to pick up and use effectively. It also tends to make better programmers, more quickly. There's a reason MIT taught Lisp/Scheme in its introductory computer science course for so many decades.

      However (1) once you've ingrained all the counter-proactive habits of thinking and worked past the stumbling blocks that imperative and object-oriented programming models present, the conceptual jump from that to SQL is smaller; and (2) good, in-depth introductory materials don't materialize out of nowhere without demand. Your instructor was probably trying to do something good, both by introducing you to data processing in a language with fewer syntactical hurdles and in year-by-year incrementally improving the quality of introductory material by using it in instruction.

      Datalog allows you to express data relationships in a more straight forward, more compact, and easier to refactor way free of most boilerplate. It does, however, require you think about what you want to accomplish abstractly, rather than as an imperative process, which is difficult merely because of the years of experience the typical student already has in unergonomic languages like C++, Java, etc.