
Ask HN: Language for Rules Engine - bpyne
I have an idea for a niche component to be used in the education market. It would require writing a rules engine, but the rules would have to be dynamic because power users would be able to change them. I have no experience writing a rules engine so I'm wondering if there is a de facto standard language used for this scenario?
======
kls
There is no standard, but what technologies are you planning on using?
Personally I would consider using one of the Lisp dialects because they are so
easy at writing DSL's you can even write it so that you have a simple DSL that
can drop back to full Lisp as people grow in their ability to write rules.
What platform are you targeting, if you are targeting the JVM then Clojure
would be a good choice, if it is the .net platform then you may have to look
at IronScheme are another variant, but they are not as well supported as
Clojure. If you have a very specific platform then you could look at using
Common Lisp.

The reason I would chose a Lisp is due to the ability to rapidly write a DSL,
so you can build a tailored language for the rules engine further you can
rapidly build variants for industry specific verticals, that conform to the
jargon of that industry.

My secondary choices would be many of the scripting languages with JavaScript
being the top second choice. JavaScript is a good candidate because it is
simple to pick up and has a lot of material geared towards the non-programmer.

For me personally I would shy away from any languadge that enforces OO, not
because I think OO is bad, I am actually a proponent of OO for certain cases,
but rather because OO brings a lot of baggage with it that creates barriers
for individuals that are not programming as a primary job role.

Finally, the idea of Rules engines have been great on paper, the promise of
turning the power of decision trees over to business annalist but the reality
has not been so favorably to rules engines. Most of the time the
responsibility of actually writing the rules is pushed right back to the
programmer. So the big thing you have to ask yourself is how is my idea
different. I am not trying to be the rotten apple in your pie. I just want to
highlight that the promise of rules engines has thus far been marred with
failure. Which tells me that more people need to innovate in that space. I
would just advise you to really question how you are going to deal with that
reality. I think utilizing a Lisp is one of the keys to a proper DSL strategy
and I think the lack of good DSL's is where rules engines have failed, hence
my recommendation.

~~~
bpyne
First off, thank you for the well thought out response.

I was far too vague with my question. I did not mean a general purpose rules
engine as in the middleware piece. What I'm thinking about is better described
as a rules based system, but far more complex than anything I've written in
the past. Just to add complexity, a few domain experts will have the ability
to modify and implement rules.

My inclination is towards a language with a small syntactic footprint and not
a lot of tribute towards system stuff like memory management. So I was leaning
towards Clojure but JS is a great thought. Other languages I wondered about
were Prolog and Scala.

I'm doing it as a learning exercise, an attempt at keeping my skills from
rusting, and because my day job is boring. If it can be monetized, that's a
bonus.

~~~
dromey
Prolog and other logic programming languages are natural rule languages. You
will want to consider the semantics that the rules are given as well as how
negation in the language is treated. It's also good to know the (worst-case)
complexity of the problems you are trying to solve and to match them
appropriately to expressive power of the rule language you propose to use.

------
dangrossman
Not that many years ago I worked at a company that had implemented a rules
engine for documenting the health and safety information associated with their
products, based on rules operating on the chemical formula of the product,
with CLIPS [1]. The rules were dynamic. You define the rules and program it in
a LISP-like language. It was embedded in a C++ program that generated and fed
the rules to CLIPS.

<http://clipsrules.sourceforge.net/>

