Replies: 3 comments 8 replies
-
@kerr would you be able to provide some code examples with some of the existing javadsl functions where coding would be easier if the Pekko javadsl method took a java.util.function as input instead of an org.apache.pekko.japi.function ? We could end up going down a big rabbit hole on this topic and so far, I haven't seen too many real world examples. I must admit to not using Java for functional programming much. I use Scala for FP and some times Java for legacy applications (that don't tend to be FP focused). |
Beta Was this translation helpful? Give feedback.
-
I've never really used the java API of Akka/Pekko. Personally I don't like method suffixes like
So |
Beta Was this translation helpful? Give feedback.
-
So lets lay things out here, the only perceived benefit I can see to either changing the current API to use
Which is an incredibly weak reason to change the entire API (I am even ignoring the fact that using hacks like
When reading an API and programming against the Pekko API in java, this to me is CRITICAL as it CLEARLY tells me for the lambda I am providing whether it makes sense for exceptions to be thrown or not, i.e. if with this allocate parameter, since its a Ontop of this, 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 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 Also it does make sense to maybe contribute |
Beta Was this translation helpful? Give feedback.
-
org.apache.pekko.japi.function package is commonly used for functions in our javadsl.
We can't just change the existing methods to use the Java built-in Function interfaces. (java.util.function package)
@kerr says that we can't add overloaded methods because the Java compiler will not be able to distinguish between the 2 overloaded methods when you try to provide lamdba functions as inputs.
We have options like
V2
in the name. An example is Flow.statefulMap which takes a Pekko Creator function as its first param. We could add a statefulMapV2 that takes a Supplier instance instead.juf
(for java.util.function) and add some variant functions there (instead of using V2 suffix) - suggested by @nvollmarBeta Was this translation helpful? Give feedback.
All reactions