Remix.run Logo
mystifyingpoi a day ago

> 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.
still_grokking 2 hours ago | parent | next [-]

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(", "))
bvrmn 15 hours ago | parent | prev [-]

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.

still_grokking 3 hours ago | parent [-]

Python's approach is one of the most confusing ways to possibly do it. Not having proper, discoverable methods is super annoying, and I need to look it up every time anew I use Python because it's so unintuitive.

Of course you can write a generic version of `mkString` (as this method is called in Scala), so it's also just one method no matter the container count.

The Python weirdness is actually a direct result from the language lacking generics…