Hi Guido, There is no overhead of calling Scala code from Java, whatever you can access from Java, and looks like a method, then it is an ordinary JVM method. In fact, sometimes calling the Scala API might be slightly faster, since most of the time the Java API just calls the Scala API underneath anyway.
-Endre On Tue, Jun 2, 2015 at 12:29 PM, Guido Medina <[email protected]> wrote: > Hi, > > I like the mix between Java and Scala and sometimes even more inclined to > Scala idiom, assume that we will eventually move from Java 8 to Scala but > for now we are stuck with Java 8, using the following two examples: > > > // Method using Scala API > private void applyToAccount(Currency currency, BalanceOperation > operation) { > final ActorContext context = context(); > context.child(currency.code). > getOrElse(new AbstractFunction0<ActorRef>() { > @Override > public ActorRef apply() { > return context.actorOf(balancePersistorProps(currency), currency > .code); > } > }).forward(operation, context); > } > > > // Method using Java 8 API, the following is shorter in Java because > Scala Option > // is not functional interface but that's an exception so probably not > the best example. > private void applyToAccount(Currency currency, BalanceOperation > operation) { > final UntypedActorContext context = getContext(); > Optional.ofNullable(context.getChild("currency.code")). > orElseGet(() -> context.actorOf(balancePersistorProps(currency), > currency.code)). > forward(operation, context); > } > > Is there a performance difference in Akka between calling Java-to-Java vs > Java-to-Scala?, I really hate to do things like getContext(), getChild(), > get..., get..., get..., stupid get in front of everything so I'm just > mixing Java/Scala together, is there anything I should be aware of or > counter indicated with my approach/taste/convention? > > -- > >>>>>>>>>> Read the docs: http://akka.io/docs/ > >>>>>>>>>> Check the FAQ: > http://doc.akka.io/docs/akka/current/additional/faq.html > >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user > --- > You received this message because you are subscribed to the Google Groups > "Akka User List" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/akka-user. > For more options, visit https://groups.google.com/d/optout. > -- Akka Team Typesafe - Reactive apps on the JVM Blog: letitcrash.com Twitter: @akkateam -- >>>>>>>>>> Read the docs: http://akka.io/docs/ >>>>>>>>>> Check the FAQ: >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups "Akka User List" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
