Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best Java Functor lib: JGA, commons functor, mango, or...?

Tags:

java

functor

I am interested in using functors (function objects) in Java. With quick googling I found these 3 packages:

  • Java Generics Algorithms: http://jga.sourceforge.net/
  • Commons functor: http://commons.apache.org/sandbox/functor/
  • Mango: http://www.jezuk.co.uk/cgi-bin/view/mango

and of 3, JGA seemed like it might have the best design. But I suspect others here who have actually used one or more of the packages might be able to offer more insight as to pros and cons of these (and perhaps other) functor packages.

like image 734
StaxMan Avatar asked Mar 16 '09 18:03

StaxMan


1 Answers

Mango

Provides interfaces for 0, 1, and 2 argument functions. Uses Java generics. Good range of algorithms for working with functions.

JGA

Provides classes for 0, 1, 2 and arbitrary number of argument functions. Domain objects subclass these. Uses Java generics. Extensive range of algorithms. Includes JFXG (Java Functor eXpression Grammar) - a parsed language intended to make it easy to create arbitrarily complex functors. Provides multiple algorithms for working with functions.

Apache Commons Functor

Provides interfaces for 0, 1, and 2 argument functions as well as 0, 1 and 2 argument procedures (which return no value). Uses Java generics. Good range of algorithms.

Google Guava (was Google collections)

Provides Function and Predicate interfaces for single argument functions. Uses Java generics. Provides only the compose method for combining functions. Pretty basic.

FunctionalJ

Provides interfaces and classes for 0, 1, 2 and arbitrary number of argument functions. Uses Java generics. Existing methods can be turned into functions via the provided function reflection classes.

like image 176
tekumara Avatar answered Sep 23 '22 21:09

tekumara