clara

2022-02-28T12:21:20.144499Z

Maybe not an appropriate question here i really like clara rules and would love to use it in scala has anyone tried it in scala or even just through java ?

2022-02-28T13:42:49.508039Z

It should work through the java API. I've heard of people using that before

PB 2022-02-28T17:39:09.419779Z

Does the ordering of constraints matter much when it comes to performance of rules?

2022-02-28T17:54:02.064049Z

@petr I think abstractly, not really. However, there are ways to write rules that perform better by reducing the set of facts needed to be tested for matches.

2022-02-28T17:54:13.866879Z

So you can logically organize rules and constraints in more performant ways.

PB 2022-02-28T17:55:03.121239Z

@mikerod thank you

2022-02-28T18:02:33.455439Z

Hypothetical example demo. @petr

ethanc 2022-02-28T18:08:03.694229Z

I will add on to what Mike said, there are scenarios where it can be advantageous to order constraints in an order that is consistent with the performance of the check. Example:

(defrule a-rule 
 [Fact 
  (a-quick-check) 
 (a-slow-check)]
 => 
 (<do things here>))
Due to the implementation of clara, “In most cases, those not being joined to other facts”, most constraints are simply “plopped” into an if block. So, in short… i guess i would recommend ordering constraints similar to how you would if you are writing an explicit if yourself… That being, if you know one check is “cheaper” put it first in an attempt to short circuit the following logic. That all being said… i might just be being pedantic with the terminology of Condition vs. Constraint. edit: or -> if

2022-02-28T18:21:23.314509Z

Good point @ethanc!

2022-02-28T18:21:34.949709Z

I was too loose with terminology.

2022-02-28T18:22:10.230289Z

I think “Condition” is better to refer to [Fact <constraints>] Where then, “Constraint”s refer to the filter within the “Condition”.

2022-02-28T18:22:59.599089Z

Also, you can note that = checks in constraints that facilitate “joins” between multiple Conditions, are specially optimized by the compiler.

PB 2022-02-28T18:24:21.373869Z

Wonderful - thank you guys so much