
Naga: Datalog-based rules engine in Clojure - espeed
https://github.com/threatgrid/naga
======
espeed
Here's Paula Gearon's ([https://github.com/quoll](https://github.com/quoll))
talk on Naga at Clojure Conj 2016:

Production Rules on Databases:
[https://www.youtube.com/watch?v=8rRzESy0X2k](https://www.youtube.com/watch?v=8rRzESy0X2k)

------
trapperkeeper79
I'm curious what the state of the art in rule engines is? I feel this is a
neglected topic these days. I'm almost surprised to see new work on the topic.

~~~
tunesmith
I'm curious too - particularly horizontally-scalable distributed rules
engines. I realize that might be contradictory since the Rete algorithm scales
by throwing memory at it, but what if you want to throw more facts at an
expert system than you can reasonably put in one server?

------
hardwaresofton
Isn't Prolog the better language for this? Don't get me wrong I love clojure,
and one of the best things about dialects of lisp is that they are pretty much
always multi-paradigm, but...

Pretty sure this is exactly what you would use Prolog for.

~~~
tannhaeuser
Exactly.

While Datalog is a subset of Prolog, Datomic isn't Datalog. From their
tutorial:

    
    
        [:db/add "foo" :db/ident :green]
    

This isn't Prolog syntax at all. Prolog would be

    
    
        assert("foo", ident, green)
    

Franz, Inc. does it as well - calling something Prolog for their Lisp product
which it just isn't.

I've nothing against Clojure but I wish the functional programming fans
wouldn't call their DSLs Prolog or Datalog. If you're using Prolog or Datalog,
you're expecting it to be (reasonably) portable accross Prologs, which this
isn't at all.

~~~
lispm
'Prolog' in Lisp exits for decades. During the 80s several Prolog
implementation had been developed for research systems and also for commercial
systems. Many used an s-expression syntax for Prolog, but some could also read
'Edinburgh' syntax.

Most of the time these 'Prolog' implementations are not as powerful/complete
like a typical modern Prolog implementation.

LispWorks for example has an expert system development extension with an
integrated Prolog.

[http://www.lispworks.com/documentation/lw70/KW-M/html/kwprol...](http://www.lispworks.com/documentation/lw70/KW-M/html/kwprolog-m.htm)

It also offers to read Edinburgh syntax and also has a command line interface
for this syntax.

[http://www.lispworks.com/documentation/lw70/KW-M/html/kwprol...](http://www.lispworks.com/documentation/lw70/KW-M/html/kwprolog-m-135.htm#pgfId-869241)

But it still is far from ISO Prolog compatible.

~~~
tannhaeuser
> 'Prolog' in Lisp exits for decades.

I sure hope so ;)

Also it's clear ISO Prolog isn't universally embraced
([http://www.cs.unipr.it/~bagnara/Papers/Abstracts/ALPN99a](http://www.cs.unipr.it/~bagnara/Papers/Abstracts/ALPN99a))
since most popular Prolog implementations based on WAM were started way
earlier.

I guess there are worse things Prolog had to suffer; namely, Perl
insensitively took away the .pl file suffix and made it its own.

------
mark_l_watson
This looks really good. Make sure to watch the talk that espeed mentions. In
the 1980s I spent a fair amount of time hacking Rete networks, mostly in a
commercial version of OPS5 I sold for Xerox Lisp Machines, and also a modified
version of OPS5 that had meta actions for spawning separate 'worlds, etc.

Rete scales well for huge numbers of rules, but not so well for large data
sets. I haven't played with Naga yet, but I am curious if that is an issue.

------
asciihacker
There is also miniKanren, available as core.logic.

~~~
saosebastiao
Seemed like abandonware the last time I tried. Has it been picked up again?

~~~
znDuff
core.logic has been in continuous commercial use pretty much from its
inception, and that continues presently. I'd argue that calling a continuously
high rate of change a prerequisite towards usefulness is an attitude which
makes more sense in communities where there's little respect for backwards
compatibility and thus a high rate of bitrot, ie. Ruby.

~~~
dkersten
Exactly. I'd rather use something stable that doesn't need much (if any)
continuous change.

