2007-06-13

Rule-Based Programming in C (DDJ article)

Rule-Based Programming in C is an article by Lynwood Wilson that I found on the DDJ website. The article's main idea is that you don't need a Rule Engine for simpler situations. Instead you can use the "native" language of your application (in this case C).

Most of the article (2 out of 4 pages) is spent discussing strategies on how to control the execution of rules (using global variables!) to avoid infinite loops and such. The C code for the various control strategies seems even more complex than just embedding the rules as normal if/then clauses. At least that has the advantage of probably being what the next programmer to look at the code expects to see.

Wouldn't these 4 pages have been better spent discussing how to embed Clips?

1 kommentar:

woolfel sa...

I'm gonna say the author of that article hasn't got a clue about how to write a proper general purpose forward chaining rule engine in C. The simple approach he described will only work for the simplest cases and won't be able to handle cases where rules modify facts. Basically, that approach would only work if rules only introduce new facts. Even then, the performance would be slow and execution control would be convoluted.