Call scala from java - performance?

I have a parser written in Scala because of the ease of implementation. I need to call it from my java application. I know that I need to include the Scala library in the classpath, etc. But what about performance? Could there be any strong performance comparing pure Java parser calls?

+4
source share
2 answers

Calling Scala from Java does not bring any overhead: all this is just bytecode when it is executed. It is not as if you had to travel through some kind of bridge between Java and Scala, as you would if you were calling from Java in, I don’t know Python.

Whether the implementation of this particular Scala algorithm is faster or slower will depend on the nature of the algorithm and how it is implemented. Given that you are not going to implement it equally in two languages, it is very difficult to predict.

+8
source

There should be no effect in theory, since Scala uses the same JVM and bytecode as Java, and all the performance tests that I have seen give roughly the same speed for both languages.

That is, it should be the same (in terms of performance) a Java library call, or so similar that the difference does not matter.

+3
source

Source: https://habr.com/ru/post/1393116/


All Articles