GitHub user mdedetrich added a comment to the discussion: Stream JavaDSL: start 
adding alternate methods that use Java function interfaces instead of the Pekko 
ones

So lets lay things out here, the only perceived benefit I can see to either 
changing the current API to use `java.lang.*` or providing a `v2` or something 
similar is this

> The core reason is that when a Java user calls these functions using new 
> xFunction, they will see a strange japi.function.Function instead of the 
> familiar java.util.function.* that they are used to. I believe this is the 
> main issue, especially for beginners. As for @exception, I don't think it's a 
> significant problem since Java streams have never provided it anyway.

Which is an incredibly weak reason to change the entire API (I am even ignoring 
the fact that using hacks like `@SneakyThrows` would be just as confusing to 
any Java beginner as would `org.apache.pekko.japi.function.*`, you are just 
trading inconvenience for another and `@SneakyThrows` is objectively worse here 
since its a hack). On the other hand, there is a very good technical and 
correct reason as to why `org.apache.pekko.japi.function.*` exists, its for 
lambda's that can legitimately throw an exception i.e. in a when supplying a 
lambda to `create` for creating a resource (such as a file) that lambda can 
throw an `IOException`. This is succinctly summarised as

* Supplied lambda should never throw (i.e. creating a collection)? Use 
`java.util.*`
* Supplied lambda could throw (i.e. allocating a resource such as a file)? Use 
`org.apache.pekko.japi.function.*`

The benefit we get (which is some small convenience for beginners) is greatly 
overshadowed by the inconvenience of either having to change everything for 
Pekko 2.0.x (we cannot do this before, it will break users) or creating an 
alternate `v2`/`juf` javadsl which to be honestly I would almost certainly `-1` 
as this is much more confusing than any other option or the status quo. If your 
goal is not to confuse beginners, then having multiple java api's will achieve 
the exact opposite effect.

Another point to keep in mind is that minor beginner inconveniences will always 
get trumped by correctness/API design as this is one of the core tenets of Akka 
and hence Pekko. If you want something easy and quick then you probably 
shouldn't be looking at Akka/Pekko in the first place. That doesn't mean we 
should make it as Pekko approachable by beginners, but it doesn't mean that 
Pekko should cater to every single minor beginner inconvenience, this is a 
slippery slope that we should not go down.

Given that there is one glaring hole, which is the this distinction of 
`@FunctionalInterface`'s in core java stdlib vs the ones in 
`org.apache.pekko.japi.function.*` doesn't appear to be generally documented 
(even though it is [clearly documented in 
code](https://github.com/apache/incubator-pekko/blob/b0fdac259bd57fdd481483f3fe9a7aec6e1ff38a/actor/src/main/scala/org/apache/pekko/japi/function/Function.scala#L18-L22)),
 due to this it makes sense to document this in the Pekko general docs 
somewhere.

GitHub link: 
https://github.com/apache/incubator-pekko/discussions/960#discussioncomment-8140746

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: 
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to