tags:

views:

461

answers:

4

I need to build a "rule-based" system that can be run and developed in both C# and Java (for a chemistry application). The system needs to be able to get computed properties of objects (through existing libraries) and make decisions on those values. I am not sure what the system will look like but the rules need not be formally consistent (we use a lot of heuristics). As far as possible the rules should be externalised so users and developers can modify them without needing to know about the engine (which should be Open Source and run on both platforms). It's possible that the system will be run through a restricted set of natural-language-like commands. There will be an element of adaptation - new objects (or at least vocabulary) can be added.

This is not as hairy as it sounds - a great deal of progress was made over 30 years ago using FORTRAN but the field has lain fallow. I'd be grateful for pointers to approaches we could experiment with where the overhead of entry was modest. Among the approaches that might work are:

  1. Prolog
  2. OWL Ontologies
  3. Decision trees
  4. RULEML
  5. Text-based games

EDIT The primary aspect of the question is to find a rule-based system (the Java C# mention is secondary and was simply to prevent answers that might say "Windows has a built-in system".) Please do not answer with approaches to converting Java to C#; I want a rule-based approach that - in principle - could be implemented on either. So far only one (or two) answers really addresses the rules aspect.

A: 

Hello,

If you want to implement your own Domain Specific Language, good options would be IronPython (Microsoft Dynamics uses it for the same purpose), or, for instance Boo language.

Vitaliy Liptchinsky
Why was this downvoted? It's not a bad suggestion. Quite likely the RuleML stuff (which I, though, only glanced) will just add complexity compared to a DSL. I'd probably go for ANTLR, though, since it can generate code for both C# and Java.
erikkallen
If there is a DSL it should be externalised (and will need a parser, so ANTLR is a useful approach for that part). But how do you write a DSL to manage the rules and allow non-develoeprs to add rules?
peter.murray.rust
+2  A: 

If you develop in Java you can use the resulting classes in .Net/C# by using IKVM. IKVM converts Java bytecode to the equivalent MSIL and also provides a Java class framework and VM all running within .Net. It works exceptionally well, it's free, is used commercially (e.g. by the Saxon XSLT/XQuery/XPath product) and it's really easy to convert a java class file to a .Net dll.

I often use Java projects in .Net for doing scientific and maths based operations because work in these fields often tends to be in Java - certainly far more often than it is in C#.

locster
This doesn't address the rules aspect. I'm less concerned about translating than working out the rules system
peter.murray.rust
+2  A: 

You could take a look at Drools (now also known as JBoss Rules). This a Rete engine implementation that has been around for quite a long time and has now also been ported to .NET so it should fill your requirements for being able to be used in Java and in C#. I don't know how close the implementations are - you might find yourself limited to a subset of the capability.

JBoss Rules: http://jboss.org/drools/

Drools.NET: http://droolsdotnet.codehaus.org/

Don't worry about the business focus on the JBoss site, Drools is a general purpose Rules Engine implementation.

Trevor Tippins
Thanks - this looks a useful thing to explore
peter.murray.rust
This is looking promising and the sort of answer I was expecting.
peter.murray.rust
A: 

You could build a rules engine as a web service, Then you can call the service from either C# or Java.

Tony Borf
This does not address the creation of the rules engine
peter.murray.rust
The point was to make it a web service so it doesn't matter what it is written in.
Tony Borf