[rules-dev] Functional programming in Drools: Brackets and Commas

Mario Fusco mario.fusco at gmail.com
Thu Oct 20 09:07:25 EDT 2011


Toni,

correct me if I'm wrong: your suggestion looks very similar to what you do
in Haskell where the syntax without parenthesis and commas is allowed by the
fact that in this language every function officially takes only one
parameter, while the functions that apparently accept more than one argument
are actually curried functions**. You can find more explanations about this
syntax, for example, here:

http://learnyouahaskell.com/higher-order-functions

Despite I like this syntax because it allows to eliminate some punctuation
making the code often (but not always) more readable I also see 2 main
problems with it:

1. It implies a larger use of curried functions and I am not sure that the
biggest part of Drools users will feel comfortable with them.
2. It will bring our syntax even farther from the one that will be available
in Java 8.

In general I agree with Geoffrey when he wrote that we should give a look at
the upcoming Java 8 syntax and stay as close as possible to it. Nevertheless
I also think that what will we have in Java 8 is not enough to make it a
functional language and, in the same way, not enough to have in the DRL the
expressiveness and features of functional programming.

My suggestion is that our syntax should be a superset of the Java 8 one,
adding to it things like currying, functions piping and tuple. I hope I
demonstrated how this features could be useful for us in my article. In this
way we will have the twofold advantage of providing a syntax that won't look
too much alien for the Java developers and possibly making our work easier
(if we will decide to build it on top of Java 8) because in that case we
will need only a (hopefully thin) layer that translates in plain Java the
functionality not natively covered by it.

Mario
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-dev/attachments/20111020/7b6bce3a/attachment-0001.html 


More information about the rules-dev mailing list