Skip to main content

Interview with lambdaj creator - meet Mario Fusco at the Java.Net Community Corner

Posted by fabriziogiudici on June 1, 2009 at 11:08 AM PDT

Functional programming has been a hot topic in recent times, at the
point that a number of


First, I'd like to stress that the comment on closure was marked as a personal parenthesis, so it's mine and not from Mario. And in any case, Mario needs feedback about lambdaj, not yet another discussion about closures ;-) In any case, right or wrong, lambdaj is here as a viable option, closure in Java aren't and, as far as we know, won't be here for years. Second, right, CGLIB and similar stuff have got a problem with final. It's something that unfortunately occurs in many other standard frameworks based on the same technique, such as JPA. I wouldn't die for the fact that I have to remove final for this reason (even though I usually advocate about using final as much as possible, but you have to accept some trade off).

You're right. Lambdaj doesn't work when you meet a final class as in your example. But of course you can find some workaround to "help" lambdaj to work as you expect. To fix the problem you're pointing out it's enough to add the method getLowerCaseLastName() to the Person class. In the end if your business logic needs to do something with the last name in lower case, maybe it is not a bad idea to add that method to your domain model in each case. As for the lack of closures in Java, I wouldn't like to start a flame here. I like closures and, as you can imagine, I developed some feature of my library with them in mind. I'm currently using some languages that support them like Scala and I feel very comfortable with it. At the same time I think that Java hasn't be thought and engineered to support closures and to add them in a second stage, as somebody is suggesting, could create more problems than it could resolve, as it has been already pointed out by Joshua Bloch in a presentation of more than one year ago.

LambdaJ looks definitely nice. But what I'm missing (also on its homepage) is some information about its limits. I guess the approach breaks as soon as you hit a final class, which means you couldn't do: ... on(Person.class).getLastName().toLowerCase() ..., right? Somehow I have the feeling it's a (really very cool, but limited) workaround for the real solution - closures.