Hello world!
J'aimerais votre avis sur le fait de faire de la programmation fonctionnelle en Java. Il existe depuis Java 8 des interfaces et des fonctions lambda mais je trouve leur utilisations un peu pénible.

En ayant suivi ce tuto sur ce site:
https://dzone.com/articles/functiona...ramming-java-8

J'en suis arrivé à expérimenter l'implémentation de quelques fonctions triviales.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 
package univ.cours.sio;
 
 
import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.function.UnaryOperator;
 
import univ.cours.utils.Utils;
 
/**
 * fonctional skills in java 
 */
public class App {
    public static void main( String[] args ) {
    	Function<Integer, UnaryOperator<Integer>> makeAdder = Utils::adder;
    	Function<Integer, UnaryOperator<Integer>> makeMultiplier = Utils::multiplier;
 
    	UnaryOperator<Integer> add1 = makeAdder.apply(1);
    	UnaryOperator<Integer> multiply5 = makeMultiplier.apply(5);
 
    	BinaryOperator<UnaryOperator<Integer>> compose = (f, g) -> x -> g.apply(f.apply(x)); 
 
    	UnaryOperator<Integer> operation = compose.apply(add1, multiply5);
 
    	Function<String, Integer> atoi = s -> Integer.valueOf(s);
 
    	Integer result = operation.apply(10);
 
        System.out.println(result);
    }
}
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
 
package univ.cours.utils;
 
import java.util.function.UnaryOperator;
 
public class Utils {
	public static UnaryOperator<Integer> adder(Integer y) {
		return x -> x + y;
	}
 
	public static UnaryOperator<Integer> multiplier(Integer y) {
		return x -> x * y;
	}
}
Je sais que la programmation fonctionelle est un paradigme assez pratique. J'aime beaucoup le fait de respecter l'immutabilité des objets (philosophie adopté par certains framework comme React), de chainé les appels de méthodes (map, filter, reduce) et de déclarer des fonctions anonymes ect.
Je sais que le langage Scala est parfaitement adapté, mais j'aimerais tout de même pouvoir faire du fonctionnel en Java.

Faites-vous de la programmation fonctionnelle avec Java ou utilisez-vous plutôt un langage plus adapté comme Scala ?

Votre retour d'expérience m'intéresse.