Functional Eye for the Java Guy

{{jfunreport
 * title = Functional Eye for the Java Guy
 * convenor = Ben, Michael
 * participants = Mike, Dimitry, Alexandro, giannis, Alexander, Elisabeth, Sven, Stefan, Aarne, Kirk, Rickard, Tasos, Michaelis, Andreas, John, Heinz and more
 * summary =

show of hands 10 people know

ugly code example

 * for "functional java"
 * 4 levels of nested classes
 * unreadable

issues with java

 * no native function types
 * all based around classes, class is smallest unit
 * SAM - Single Abstract Method (interface) (no state, one method)
 * inner classes (Class$Inner), hold on to outer class references
 * closing about context, final outer variables

when do you use FP

 * list comprehensions
 * composable functions
 * reusable code

OO vs. FP

 * OO -> box with state which contains method that change that state all the time
 * FP -> functions are transformations, side-effect free
 * higher order functions

what is the difference to methods in a object that just use ? -> still access to mutable object state/context

some examples in clojure

 * schwarz function (a bit too complex)
 * sorts a list by a user defined function
 * introduced defn, map, sort-by, lambdas, list, let, nth
 * simplified (sort-by f x)

Rickard :


 * Specification -> composable predicates that return boolean values -> usable for filtering
 * filter, map -> function applications to sequences/lists

smalltalk example by Kirk

 * if, while statement implemented using language constructs (blocks)

Partial audio recording
Audio recording

}}
 * recommendations = (as above)