I love this! If you’re wondering where this is used these days… Open Policy Agent is an authorization rules engine that uses rules written in Datalog (they call their variant “Rego”), and it’s fairly popular at various SaaS companies for making sure the right users can access the right API calls based on the properties of the users and the properties of the API calls. The key advantage of Datalog for this is that it is not Turing-complete so completion time is bounded (and in practice is extremely fast, a couple ms).
It’s interesting how the bottleneck of understanding seemed to be around the concept of relations. I’ve seen this when explaining relational logic to others, and I imagine that I must have experienced it myself at some point.
Yeah; it was interesting. I was familiar with the concept from my undergrad logic classes – I could have defined relations, going into this. But it was quite a leap to figuring out how to “wield” them in this context. It was hard to shift into that declarative mindset. It was like… I knew what an axe was, but I’d never actually had to fell a tree before. I feel like I must have had similar trouble the first time I tried to write complex SQL queries – how do I write a for loop here? – but I’ve mostly forgotten what that was like.
Honestly, really gnarly SQL queries make my head swell in ways a lot of other code doesn’t. Set based thinking can be tricky. (For context, one of the largest stored procs at work is like 8k loc.)
Though this is variously due to the relatively low level of abstraction in SQL and how nasty some queries get.
For those who want more there’s “What You Always Wanted to Know About Datalog (And Never Dared to Ask)” [ pdf ]
What a great
sed
tutorial!Best usage of a logic programming language I’ve seen!
Also a really useful way of demonstrating its database-like properties.
I love this! If you’re wondering where this is used these days… Open Policy Agent is an authorization rules engine that uses rules written in Datalog (they call their variant “Rego”), and it’s fairly popular at various SaaS companies for making sure the right users can access the right API calls based on the properties of the users and the properties of the API calls. The key advantage of Datalog for this is that it is not Turing-complete so completion time is bounded (and in practice is extremely fast, a couple ms).
It’s interesting how the bottleneck of understanding seemed to be around the concept of relations. I’ve seen this when explaining relational logic to others, and I imagine that I must have experienced it myself at some point.
Yeah; it was interesting. I was familiar with the concept from my undergrad logic classes – I could have defined relations, going into this. But it was quite a leap to figuring out how to “wield” them in this context. It was hard to shift into that declarative mindset. It was like… I knew what an axe was, but I’d never actually had to fell a tree before. I feel like I must have had similar trouble the first time I tried to write complex SQL queries – how do I write a for loop here? – but I’ve mostly forgotten what that was like.
Honestly, really gnarly SQL queries make my head swell in ways a lot of other code doesn’t. Set based thinking can be tricky. (For context, one of the largest stored procs at work is like 8k loc.)
Though this is variously due to the relatively low level of abstraction in SQL and how nasty some queries get.
[Comment removed by author]