Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Differences between Akka Scala and Java [closed]

Tags:

java

scala

akka

I am considering using Akka in one of my projects, but I have to use only Java. A majority of the material (books/articles) are on Scala version, so I am wondering if I use Java I would be a second-class citizen. Are there any significant functional/performance differences between the two?

Thanks

like image 838
LotusPetal Avatar asked Jan 06 '14 07:01

LotusPetal


People also ask

Why Akka is used in Scala?

Akka is built with Scala, but offers both Scala and Java APIs to developers. At the heart of Akka is the concept of Actors, which provide an ideal model for thinking about highly concurrent and scalable systems. Writing concurrent systems using traditional low-level mechanism such as locks and threads is difficult.

Is Scala more performant than Java?

The study concluded that Scala was faster than Java and Go when average developers write their code without thinking about optimization too much. The study used the default, idiomatic data structures in each language.

Is Scala slower than Java?

Scala is generally considered slower than Java, especially when it's used in a functional style.

What is Akka used for?

Akka is a toolkit for building highly concurrent, distributed, and resilient message-driven applications for Java and Scala. Akka Insights is intelligent monitoring and observability purpose built for Akka.


3 Answers

In terms of performance of Akka itself it will be the same since you are going to be running the same Akka byte code. However in terms of integrating you will be using the Java API and be limited to the language features of Java. As such you will be a second-class citizen in terms of using the API. However in functional and performance terms it will be pretty much identical. Just keep in mind that your Java code will be interacting with the library differently from Scala code. With Scala you have access to closure and other constructs that you cant use with Java (yet). Nevertheless Akka is a great library also when used from Java....

like image 182
Manfred Moser Avatar answered Oct 31 '22 10:10

Manfred Moser


I think the main web site page on Akka sums it all: 11 lines of Scala, 17 lines of Java (+50%).

No or negligible performance difference (bytecode, JVM,...). The performance issues will be around what you write on top of Akka.

Significant functional performance (not in terms of possibilities but code clarity... and clarity has a direct relationship to bugs and fixing them)

like image 20
Bruno Grieder Avatar answered Oct 31 '22 10:10

Bruno Grieder


Between the two implementations, there are no differences in terms of performance and functionality. If your formation is Java then Akka can be a good solution to introduce the actor model in your Java projects. Clearly with Scala would have the advantages that the whole expressiveness of the language offers.

like image 24
Marco Avatar answered Oct 31 '22 10:10

Marco