This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-03-03
Channels
- # announcements (2)
- # babashka (154)
- # beginners (63)
- # calva (4)
- # cider (2)
- # clara (19)
- # clj-kondo (94)
- # cljfx (8)
- # cljs-dev (6)
- # clojars (2)
- # clojure (82)
- # clojure-australia (1)
- # clojure-europe (134)
- # clojure-italy (4)
- # clojure-nl (5)
- # clojure-serbia (11)
- # clojure-taiwan (1)
- # clojure-uk (39)
- # clojurescript (83)
- # community-development (108)
- # conjure (10)
- # cursive (32)
- # data-oriented-programming (1)
- # datomic (22)
- # defnpodcast (9)
- # depstar (4)
- # docker (3)
- # events (3)
- # figwheel-main (2)
- # funcool (9)
- # graalvm (19)
- # honeysql (23)
- # jackdaw (4)
- # jobs (4)
- # jobs-discuss (2)
- # kaocha (24)
- # leiningen (1)
- # lsp (12)
- # membrane (6)
- # off-topic (21)
- # pathom (13)
- # polylith (1)
- # releases (7)
- # remote-jobs (2)
- # reveal (8)
- # ring (7)
- # sci (2)
- # shadow-cljs (9)
- # sql (10)
- # tools-deps (21)
Yeah, additionally my previous statements also glossed over: > There aren't any rules Clara doesn't make distinctions between rules and queries in the context of fire rules, they are both productions in the session and are treated in very similar ways.
I'm still figuring out "what is a rule engine good for" My specific use case is for a complex ordering system, sort of like a restaurant. Where a customer might order a "veggie burger" and I was thinking that the rule system could be used to build out the list of ingredients and compute their final cost and perhaps caloric impact. And allow for variations, like extra mustard etc... So my thought was the menu and its items would be the initial facts, and then the "orders" facts are mixed in - then the output is several detailed views (or queries)... The bill, the ingredient list, the caloric breakdown. Is this an appropriate hammer for this problem? In particular I like the way you can "audit" the outcome by looking at the detail of which rules fired and why. (For example, to see the extra pepers caused the price to change.)
Often these are problems that would involve lots of tangled nested conditional logic, and where the domain rules have sufficient inter-relatedness that they resist easy breakdown into simple components.
(For example, imagine modeling a tax code, where taking a certain deduction might result in adjustments to multiple computed figures, and might also mean that you can’t simultaneously take another deduction that you would otherwise be eligible for.)
Yea, I tend to think of a spreadsheet (although I use those rarely) but I think of the data cells as facts, and as some cells having forumula - rules.
I think rules engines were once were pushed heavily as a way to do business logic without needing developers. I think that perhaps had some success, but I think it is missing a lower level target that is valuable - and still can involve developers
It’s really this issue of how conditional logic can build up over time and become quite tangled. Let’s keep in mind that Clara puts emphasis on the truth maintenance system sort of approach to rules engines as well.
So it allows for a level of decoupling of conditional logic and making it potentially much less order sensitive (ie. declarative)
And since it’s a structured way to somewhat declaratively represent this logic, you can fairly easily add automatic “auditing” (why facts were derived) structure over it in various ways. We’ve discussed this before a bit here with “supporting facts” or “contributing factors”
I have somewhat contrived example I used for this blog post (and associated clj/conj talk) years ago. http://www.metasimple.org/2017/02/28/clarifying-rules-engines.html I’ll share it since I at least attempted to make some “conditional” logic become tangled in a more traditional functional data-flow approach with no rules. Then showed how to rethink it via rules instead and examine the difference.
Agreed with the above. In terms of things many people would be familiar with, enn’s example of a tax code I think is a good one. There comes a point in the complexity of that kind of logic where expressing it with non-declarative approaches becomes quite challenging and IMO exponentially more difficult as new conditions are added. I informally think of a rules engine as being able to reduce such problems to “linear complexity” relative to the number of requirements.