Re: Ruby + DSLs = Power Tool "Ecosystem"
Posted: Jan 27, 2008 1:25 PM
James Watson posted:
> One of the best examples (IMO) of a DSL tool is the Drools
> rules engine that allows you to apply DSLs as
> transformations to the rule syntax...
Nice link! Thanks much. I wasn't aware of that engine.
A little searching led me here:
That page gives us:
Drools is a business rule management system (BRMS) and an enhanced Rules Engine implementation, *ReteOO*, based on Charles Forgy's Rete algorithm tailored for the *Java* language. More importantly, Drools provides for Declarative Programming and is flexible enough to match the semantics of your problem domain with Domain Specific Languages, graphical editing tools, web based tools and developer productivity tools.
Ok. So we're looking at a Java-based implementation of something called ReteOO. Interesting stuff! A little more
searching, and we get:
This is /very/ interesting stuff. But here is where things get interesting: Is Drools *open* or *closed*? (Martin Fowler uses the terms "internal" and "external", but I don't think they communicate as well as open and closed.)
Here's the difference:
A /closed/ DSL is implemented as a standalone language.
It exists outside of a programming language, so it
is "external", in that sense. But the salient feature
is the fact that you can only do things with it that
the language designers anticipated.
An /open/ DSL is implemented as an extension to a
a programming language. In that sense, it is "internal".
You plugin the new module, and you have access to both
the DSL and the underlying general purpose programming
language (GPL). It's "open" in the sense that you can
do anything you want to in the GPL, you just have the
DSL as a convenience whenever it makes sense.
Of course, there is a downside to the openness. If domain experts like to do their own coding, and they make a mistake, the could conceivable right legal GPL code which would be executed with unintended consequences, instead of diagnosed with an error, as with a closed DSL.
But in return for that risk, you throw off the shackles and can do anything at all you want to do. (The aristocracy had essentially the same argument over democracy!)
So is Drools open or closed? I'm guessing closed, since Java isn't designed to "extend itself" into a DSL. But you're darn right that Drools is a useful tool to have in your bag. And Java remains a very readable, hence maintainable language.
For a large installation then, Java + Drools may be the way to go. For agile coding (the most fun kind!) I'm inclined to stick with (J)Ruby--at least for the moment!