When we initiated JSR-331 standard, the choice of Java was justified (besides other practical advantages) by the fact that users would be able to create their own friendly DSLs (domain specific languages) using different JVM languages. Probably it will be interesting to look how a notorious SEND+MORE=MONEY puzzle can be presented in different JVM languages. We will show it in basic Java, Groovy, Scala, and Closure.
Java with a basic JSR-331 API:
Groovy:
This code is based on my experiments with Groovy two years ago. Here, contrary to a pure Java, we at least may see normal overloaded operators defined on constrained variables.
Scala. A few year ago Noel Lynch created a very basic Scala’s wrapper for JSR-331. Here is his version of SEND+MORE=MONEY:
Today there is a full-blown version of a CP solver written completely in Scala – see OscaR. It is not JSR-331 compliant but hopefully we will work with Pierre Schaus on the integration.
Clojure. I’ve just posted a message about a JSR331-based Clojure environment created by Oscar Riveros. Here is his code:
Please share your experience.
Thanks for the link to OscaR. We should organize a competition for JVM solvers (like minizinc).
Hi Pierre,
We certainly can do it. However, I expect to add an implementation of the Problem’s methods storeToXML() and loadFromXML() to the common JSR331 support library. It will use the MiniZinc format. Choco 3 already has such an implementation now and hopefully they will share it with us soon. JaCoP has its own MiniZinc interface as well. So, when we have one common interface, all JSR331-compliant solvers will be able to participate in MiniZinc competition. Let me know if/when you are ready to create an OscaR-based implementation of JSR331 – I’d be glad to be in help.
Jacob