Integration of Scala in C++ application

Dear community,

I’d like to use my Scala-based app into a C++ based application, e.g. calling a Scala excutable inside the C++ app. I saw that this could be done through java (jar file ?) but I am not sure. I saw also GraalVM.
Had someone already worked on this before ? How can this be done ?
Thank you for any kind of advice,
Best regards,

you should look at scala-native. https://github.com/scala-native/scala-native

1 Like

Thank you.

What is the main difference between GraalVM and Scala-native with pros/cons please ?

Both run natively but Scala Native has its own runtime with fast GC and integrates seamlessly with C/C++ via the LLVM compilation+linking pipeline.

More on similarities and differences here:
https://medium.com/virtuslab/revisiting-scala-native-performance-67029089f241

1 Like

@DavidGoodenough1 @bjornregnell
Thank you.
Could you be more specific about the steps or provide a simple example of C++ to Scala and Scala to C++ ? I tried to understand on the Scala native website but I am still confused on how to do that efficiently. I didn’t found a clear step by step tutorial.
Thank you very much

What about making Scala in the JVM and the C++ program communicate through some kind of IPC such as grpc? Hazelcast has a C++ client. There are many options. GRPC is modern and efficient, I would say.

2 Likes

Hi,
Do you have some experience/example implementing this solution ?
Thank you,
Best regards

It’s easy to google. Here is something: Java | gRPC

1 Like

Thank you.
Best regards.