Ask HN: Advise on building a Rules engine

1 points by famoreira ↗ HN
I have a need to build an app (Ruby) that allows the user to select one or more patterns and in case those patterns are matched to proceed and complete a set of actions.

While doing my research I've discovered the new (to me) field of rules based systems and have spent some time reading about it and it seems exactly the kind of functionality I need.

The app will be integrated with different web services and would allow rules like these one:

When Highrise contact is added and Zendesk ticket is created do add email to database

I had two ideas to build this. The first is to build some kind os DSL to be able to specify the rule conditions and build them on the fly with the user input.

The second one is to build some rule classes each one having a pattern/matcher and action methods. The pattern would evaluate the expression and return true or false and the action would be executed if the match is positive.

The rules will then need to be persisted and then evaluated periodically.

Can anyone shed some light on this design or point somewhere where I can get more information on this?

Thanks

5 comments

[ 2.7 ms ] story [ 19.0 ms ] thread
Why not use a Prolog backend to handle all of that? Starting to write your own DSL seems like a risky decision, especially if you're new to the field.
Prolog do seems to fit exactly what I need. Do you have any good resources on getting started on Prolog and maybe how to best integrate the rest of the app?
I only learned Prolog in an academic context, so I unfortunately have little knowledge about the best way to integrate Prolog with a ruby/python/other app.

Concerning resources, this is a good start that will give you a good overview of how Prolog works: http://www.learnprolognow.org/lpnpage.php?pageid=online

Save a bunch of time and just use Drools.
Drools seems to be the preferred solution in the Java world. I'll take a deeper look at it. Thanks!