Dion Almaer:
he met the author of
Quaere, which is an implementation of LINQ for Java. It's functional; the MS examples work; it's a way of representing iterable data in a relational format, more or less. Interesting stuff.
From the introduction:
Examples To import the DSL into any Java class, simply add the following import to the class: import static org.quaere.DSL.*;
Below is an example of a simple query that selects the numbers less than five from an array of integers:Integer[] numbers = {5, 4, 1, 3, 9, 8, 6, 7, 2, 0};
Iterable lowNums = from("n").in(numbers)
.where(lt("n", 5))
.select("n");This query uses a projection expression to select the names of all products in the array: List products = Arrays.asList(Product.getAllProducts());
Iterable productNames = from("p")
.in(products)
.select("p.getProductName()");The following query creates a sequence anonymous class instances with two properties containing the upper and lower case versions of the words in an array. The classes in the upperLowerWords collection will have two strongly typed JavaBean properties:String[] words = {"aPPLE", "BlUeBeRrY", "cHeRry"};
Iterable upperLowerWords = from("w")
.in(words)
.select( create( property("upper", "w.toUpperCase()"),
property("lower", "w.toLowerCase()") ) );
This is a great example of a DSL implemented with Java - and entirely usable
from standard Java code.
Do you think you'd find a good use for it in your code?
Of course, on the subject of DSLs, Ola Bini weighs in with
Concurrent DSLs:
With all the current talk of DSLs and concurrency, what I find lacking is discussions about how to combine the two. Of course, domain specific languages are incredibly important - they create a logical separation between the implementors of the business logic, and the people implementing the actual implementation of the DSL. Does it seem like a strange idea to want many DSLs to be able to run parallel to each other? I would imagine that in most cases a DSL that describes business rules and business logic is sequential in the particulars, but that there are also larger concurrency possibilities. This should be totally invisible for the business rule implementor in most cases - the runtime system should be able to run everything as efficient as possible.