Functional Java

by Max Rohde,

+++Google Guava+++

Google Guava is a collection of libraries provided by google under Apache licence to support a number of common problems in developing Java. It also provides a number of interfaces and implementations, which allow to develop in a more functional style. A good tutorial on these can be found here and here.

+++Lambdaj+++

I think it is a very interesting approach to use Java鈥榮 flexibility to write Java code, which matches the style of other programming paradigms. In this context, the lambdaj project seems to be an interesting and already quite mature framework.

Advantages: I stumbled across this project after checking out Hamcrest, which seems to be a quite popular tool for JUnit test. I was asking myself why, when it is easier to define test cases in this functional way, why not write code like this in the first place. And I believe for at least some instances writing code in lambdaj style can be much easier to read and understand.

Limitations seem to be:

  • Many operations take around three times longer than the traditional java solution
  • There seem to be some limitations in regards to generics
  • Although this might not be relevant for many, the heavy use of reflection in lambdaj prevents from using the library in GWT applications.
Categories: java