11 ms·
Java is still pretty ugly when you have to use the functions api https://docs.oracle.com/javase/8/docs/api/java/util/function/package-summary.html https://docs.
by eweise 3y ago
Java is still pretty ugly when you have to use the functions api https://docs.oracle.com/javase/8/docs/api/java/util/function/package-summary.html https://docs.oracle.com/javase/8/docs/api/java/util/function.... I don't know why they can't make it like kotlin and scala where you just can just type the function definition instead of trying to find a class that represents what you want. This streams API for example, is unreadable.
<R> R collect (Supplier<R> supplier, BiConsumer<R, ? super T> accumulator, BiConsumer<R, R> combiner)
- DarkNova6 3y agoI see the opposite. I think functional implementation of interfaces is lacking in Kotlin big time. The fact that you see a type like Comparable<T> and can implement it with an anonymous function is unique to Java. In other languages you would have Function<Int, T, T> which simply baffles the mind. Java has a powerful and performant model which also benefits from static and default methods (e.g. functional composition). Granted, the collect endpoint looks pretty wild but in 99% of cases you will simply use ".toList" or Collectors.toSet().
- eweise 3y agoI just meant that its much nicer to read and write (T) -> R vs Function<T,R> Maybe Kotlin lacks implementing interfaces functionally but in practice, I can't remember it being a pain point. Funtional programming in Java to me, still feels very clunky compared to scala and kotlin.