JSR-331 in different JVM languages

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:

SENDMORY.java

Groovy:

SENDMORY.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:

SENDMORY.scala

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:

SENDMORY.closure

Please share your experience.

About these ads

About jacobfeldman

CTO at www.openrules.com http://www.linkedin.com/in/jacobfeldmanopenrules
This entry was posted in Uncategorized. Bookmark the permalink.

2 Responses to JSR-331 in different JVM languages

  1. Thanks for the link to OscaR. We should organize a competition for JVM solvers (like minizinc).

  2. jacobfeldman says:

    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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s