logoalt Hacker News

mystifyingpoilast Sunday at 7:32 PM2 repliesview on HN

> My understanding is that Java added a lot of functional programming

This is true, but needs more context. Java 8 added Stream API, which (at this time) was a fantastic breath of fresh air. However, the whole thing felt overengineered at many points, aka - it made complex things possible (collector chaining is admittedly cool, parallel streams are useful for quick-and-dirty data processing), but simple everyday things cumbersome. I cannot emphasize how tiring it was to have to write this useless bolierplate

  customers.stream().map(c -> c.getName()).collect(Collectors.joining(", "))
for 1000th time, knowing that

  customers.map(c -> c.getName()).join(", ")
is what users need 99.99999% of the time.

Replies

still_grokkinglast Monday at 10:44 PM

It's such a blessing to be able to write in Scala

  customers.map(_.name).mkString(", ")
instead of the Java bloat

  customers.stream().map(c -> c.getName()).collect(Collectors.joining(", "))
bvrmnlast Monday at 9:59 AM

It bothers me that majority of languages ignores a nice python approach. `', '.join(any_str_iterable)`. Instead of supporting join for myriads of containers there is a single str method.