This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-05-02
Channels
- # announcements (12)
- # babashka (7)
- # babashka-sci-dev (46)
- # beginners (35)
- # biff (1)
- # calva (4)
- # cider (22)
- # clj-kondo (48)
- # clj-on-windows (4)
- # clojure (132)
- # clojure-europe (161)
- # clojure-germany (1)
- # clojure-nl (2)
- # clojure-uk (5)
- # clojurescript (39)
- # conjure (10)
- # core-typed (1)
- # cursive (48)
- # datalevin (6)
- # datascript (12)
- # datomic (9)
- # emacs (5)
- # events (1)
- # figwheel-main (2)
- # honeysql (7)
- # hyperfiddle (35)
- # improve-getting-started (8)
- # introduce-yourself (4)
- # london-clojurians (1)
- # off-topic (20)
- # podcasts (1)
- # re-frame (45)
- # reitit (5)
- # releases (2)
- # rum (7)
- # shadow-cljs (20)
- # spacemacs (4)
- # tools-build (58)
- # tools-deps (19)
- # xtdb (56)
Hey, I'm looking at rules engines, that work with datascript. I've been digging into (https://github.com/frankiesardo/minikusari) I've been using it as a really nice way to manage application complexity which is really simple to understand as it's just a function. One thing I've been thinking about is performance, there's a pretty decent thread here[0] that covers datascript performance issues which I'm slowly reading through, as well as alternatives. Are there any solutions that people are aware of that are both a reasonably performant datastore and are compatible with "rule engines"? Btw, I'm not tied to this approach, if someone can suggest something more elegant, I'd be happy to give it a go š... More detail in the thread, so I don't clutter up the channel! ⢠[0]: https://clojurians.slack.com/archives/C07V8N22C/p1615872613002600
minikusari
's implementation:
(defn r
"Tries to match rule against db
Returns tx-data or empty list if rule does not match"
[{:keys [when then args]} db]
(let [syms (for [row then el row :when (symbol? el)] el)
results (apply d/q {:find syms :in (cons '$ (keys args)) :where when} db (vals args))]
(for [match results tx then]
(let [swaps (zipmap syms match)
f (fn [x] (if (coll? x) x (get swaps x x)))]
(walk/postwalk f tx)))))
Have you seen https://github.com/oakes/odoyle-rules? It's not datascript/datalog compatible, but it's similar syntax
Let me know if you end up oaks library, I'm currently messing with it and I'm curious what other people think.
At the moment I haven't, I've found that function I linked above is currently good enough.
Once I've gotten a few more rules working and I want to see what the performance side of things looks like, then I'm planning on looking at odoyle-rules
.
My current plan (which maybe a terrible idea) is to benchmark it against sqlite
in memory mode, my existing implementation (which it will probably beat handily). clara-rules
and neanderthal
. I'm aiming for a balance of performance and easy to maintain rules...
What is the "it" your benchmarking? The fn above?
I'm clueless, what would that have to do with sqlite?
sqlite would be another way of representing data in a consistent way and processing it using rules, in a similar format to what I'm doing with :when
and :then
semantics above.
There are clojure libs that can turn datastuctures into sql statements and then I can take my rules (a list of sql expressions evaluated in order where if they return rows, what should be run against the result) as well as the application state (current db state) and basically that would be my application. Schemaverse is an example of an application built like that [0].
odoyle and clara do something similar, though they do some additional things as they're intended to be truth maintenance systems. I'm not yet certain that I ned the extra features this provides.
⢠[0]: https://github.com/Abstrct/Schemaverse
I understand, thanks!