Why java.util.function doesn't define specialized functional interfaces for all primitive types?
functional-programming, java, java-8
Solution
This was decided in order to prevent API size explosion. Being forced to introduce primitive specializations at all is already a pain point, so the compromise was to specialize only for the essential types, which are `long` and `double`, and additionally for `int` as the most prominent primitive type: the type of array indices and integer literals. All other types can be promoted to these.
In this post on the lambda-dev mailing list you can read the official statement from Brian Goetz.
Problem
Java 8 provides several functional interfaces in package `java.util.function`. For each basic function (Function, Consumer, Predicate, Supplier...) there are other defined where the type parameter is specialized for the following primitive type: double, int, long. This questions is about the motivation of such interfaces: Why are there primitive functions like DoubleFunction in Java 8 But why not all the primitive types are covered (e.g. float is missing)?