Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call scala from java - performance?

I have parser written in Scala due to implementation simplicity. I need to call it from my java application. I know I need to include scala library in the classpath, etc. But what about performance? Could it be any strong performance decreases comparing the pure java parser calls?

like image 272
MaSEL Avatar asked Dec 22 '22 03:12

MaSEL


1 Answers

Calling Scala from Java isn't going to incur any overhead: it's all just bytecode when it executes. It's not as if you were having to travel through some kind of bridge between Java and Scala, as you might if you were calling from Java into, I don't know, Python.

Whether the Scala implementation of this particular algorithm is going to run faster or slower will depend on the nature of the algorithm and the way you'd implement it. Given that you're not going to implement it the same way in the two languages, it's very hard to predict.

like image 174
Andrew Spencer Avatar answered Jan 13 '23 16:01

Andrew Spencer