Thursday, November 09, 2006

JFDI a new Business Action Scripting Language

We are working on a new non-imperative conseqeuence language for JBoss Ruless, called JFDI which is a sort of business action scripting language. We have placed this project over at Codehaus as we are hoping that it will get taken up by other declarative systems, whether they are rule or process engines.

When we first thought about doing this we got a deluge of emails like "have you looked at groovy, rhino, judoscript etc" - the answer was obviously "yes". The last thing wanted to do was yet another language and we looked hard into using those languages, but they all fell short. Not short in features, but short becuase they did too much!!! Here was the main feature set:
1) A rule consequence should be "when this then that", not "when this maybe that", its quite simply a list of actions to be performed when this situation occurs. Therefor it should not contain any imperative code, no "if", "switch" statements, its purely focused on expressions, method/function calls and we will allow a foreach loop. If someone needs to do some imperative code it should be encapsulated within a method or a function which is then called from the consequence.

2) The language should not be ambiguous and thus should be typed, although we may eventually allow type inference. Support for refactoring is definitely a long term goal.

3) A rule base may have thousands of rules, currently with JBoss Rules you end up with a minimum of two classes per rule and then a further class for each function, predicate, return value or 'eval' used. This large number of classes can cause a number of problems from perm gen issues to slowing down the system's classloader. Therefore it must be able to run interpreted, no bytecode generation. A consequence can be serialised to disk and lazy loaded on first use. While this is interpreted, as much as possible is done at "compile" time with no runtime introspection, so it's a tree of cached java.lang.reflect.Method calls. Although eventually we would like optional bytecode generation optimisations, but generally it is not the execution of the consequence that is the bottleneck.

4) A simple groovy/ruby like expression syntax. We need non-verbose ways to reference sub fields and to declare and reference maps and arrays, with support for inline anonymous maps and arrays. We would like further support for variable interpolation and <<EOF type stream writing.

5) The traditional way to "inject" variables into a scripting language is to put each key/value pair into a dictionary or context. We use to do this before drools-2.0-beta-14, it is not performant, instead we need to allow the application to determine at compile time how to resolve those external variables.

6) We need to be able to decorate a variable, at compile time, with additional methods - this way in a consequence a user can do "myVar.getFactHandle()" even if the variable itself does not support that method.

7) Native support for more complex types like BigInteger, BigDecimal and currency types is needed - so we need more control over that.

8) In-built support for FactTemplates (a better DynaBean) so they can be used as if they were real classes.

9) A less verbose way to set setters "instance(field1=z, field2=42)". Ability to call a constructor and set fields in a single statement "new BarBaz(field1 = "val", field2 = "x")".

10) The dependancy must be small, a few hundred kb.

Bob McWhirter has been busy beavering away on this and the project is getting to an almost useable state; although there is no content on the website you can start to look over the unit tests to get an idea of how the language is turning out.

A quick look at the language itself:

instance.field = value;
instance(field1=z, field2=42)["key"] = value;
instance.array[0] = value;

// method call with an inline map and array
instance.method( [1, 2,"z", var], {"a" => 2, "b" <= c} );

// standard constructor
bar = new BarBaz("x", 42)

// calls default constructor, THEN setters
bar = new BarBaz(field1 = "val", field2 = "x")

We are still trying to decide on the for each loop syntax. Bob wants to offer both the crappy java5 syntax (otherwise people will complain) and something more readable:

foreach item in collection {
func2(index) # index available automatically as a counter?

For ( item : collection ) {
func2(index) # index available automatically as a counter?

We don't just plan to use this language for consequences, it will also be used from predicates, return values and 'eval's as well as the upcoming 'accumulate' and 'from' conditional elements.

$cheese : Cheese( /* additional field constraints go here */ )
from session.getNamedQuery("thename").setProperties( {"key1" => "value1", "key2" => "value2" }).list()

So if you like what you see why not roll up your sleaves and get involved. A free T-Shirt to the first person that hassles bob to apply some patches :)

Post Comment


  1. does hassling bob without patches get a free t-shirt :)

    sorry, couldn't resist making a joke.

  2. Sure, anyone that hassles bob with anything can have a free T-Shirt.

  3. Your friends have just invited you to join the new geneRacetion, the social network for drivers in your area. Meet, share and just hang at this free site dedicated to your community of drivers. Show them your support and join for free and don't forget to pass the word. Tell them n8 drove you over.

    The site is called, check it out.

    The Pit Crew

  4. This comment has been removed by a blog administrator.

  5. If you would like to be listed in our Links Directory,
    please Contact Us.To be considered for inclusion in our Links Directory:

    We would appreciate a link back to our website.
    When you contact us to request inclusion in our Valued Links Directory,
    please let us know where you have placed a link back to our site from yours.

    Thank You!

    Link Partners
    Recommended Links to Useful Resources on the Internet
    Below are links to a variety of useful, interesting, and valuable resources on the Internet.
    Wallpaper Search Engine Web Site Design and Search Engine Optimization - Our innovative design team creates and maintains leading edge web sites, search engine applications.

    Canada B.C WebDesign is a website design company that offers website design and creation for companies, including website creation, e-commerce and more.

    Canada Logo design.Become a premium member and get unlimited access to these website templates, which you can use to create high quality website design.

    Vancouver BC web design & internet marketing by professional web designers, programmers and Certified Internet Website Design company.

    Canada Website Design services Web services firm specializing in website planning, ... Website Design & Development · Search Engine Marketing.

    Vancouver bc web design We are professional website designers providing services from website design to ecommerce solutions and real estate

    Vancouver Logo design, stationery design, graphic design and website design by experienced design professionals.

    Vancouver logo design offers professional Logo Design Service including 3D logo templates, web icons and stationery design for your company and business.

    Vancouver Web site graphic by an award winning graphics firm serving the Greater Vancouver Area. We'll make your business look good!

    Best Vancouver Logo Design offers company logo and graphic design services that include letterheads, brochures and business cards, custom made at affordable prices.

    Vancouver web design Vancouver, website design, web promotion, development company, web programming, real estate web design, graphic design

    Wallpaper Search Engine Web Site Design and Search Engine Optimization - Our innovative design team creates and maintains leading edge web sites, search engine applications.

  6. I am interested in using MVEL instead of our homegrown EL inside a larger product for efficiency reasons (development and runtime). Interested in point:

    6) We need to be able to decorate a variable, at compile time, with additional methods - this way in a consequence a user can do "myVar.getFactHandle()" even if the variable itself does not support that method.

    How do you achieve this in MVEL roughly speaking?

  7. I don't think Mike added this feature in the end, best to double check on the MVEL mailing lists.

  8. Your post is really a good one. thanks for sharing. If you want to know about more web design services so you can visit below :

    Web Design Services

  9. your look so professional in this field, JFDI is a development language, its and actionscript language and more its an object-oriented programming language like java, and other. good and very knowledgeable work.

    Dubai Website Development