logoalt Hacker News

breadwinnertoday at 2:18 AM2 repliesview on HN

> that tends to get in the way of complex error handling.

Agree. In Java, Streams allow you to process collections in a functional style. This feature enables concise, expressive data manipulation with operations like map, filter, and reduce.

Some people point out that Java's checked exceptions spoil the simplicity and elegance of Streams by forcing you to handle exceptions.

But that's not a reason to not have checked exceptions, it is a reason to not do functional style composition when methods can throw exceptions. Streams was invented for collections, which tend not to throw exceptions. If proper error handling is important don't do Streams.


Replies

tomberttoday at 2:51 AM

The Java streams are cool and I like them, but they're not a replacement for a functional type system or a functional language.

`map` is a lot more than a fancy for-loop for lists and arrays; it's about abstracting away the entire idea of context. Java streams aren't a substitute for what you have in Haskell.

dioniantoday at 3:36 AM

Yes, they are really a poor emulation of scala which makes it a bit more usable.