Scala native advantages over c++ and rust

what advantages does scala native have over c++ and rust, with respect to performance, and as a better system programming language, (although i’m aware that scala native is still in beta).

Scala Native has no benefit over C++ or Rust with respect to performance. C++ has been honed for extreme performance for decades, and performance is one of the most important considerations (after correctness) for Rust. Scala Native may sometimes be competitive, but overall you would never choose it over C++ or Rust for speed. (In fact, you might not even choose Scala Native for speed over Scala on the JVM or Graal–it depends on exactly what the workload is.)

The advantages of Scala Native are that you can interoperate fairly easily with C libraries, the startup is fast, and you can still write Scala, which has a type system that is considerably more expressive than Rust’s and vastly more expressive than C++'s; plus, you have access to much of the Java standard library, basically all of the Scala standard library, and the C standard library out of the box.

It’s difficult to give a brief list of bullet points regarding whether this is better or worse for you. Rust’s ability to make mutability safe via ownership is amazing, but Scala’s ability to express patterns that are common across data structures is also amazing. (Neither does the converse at this time.) If performance is extremely important, you will choose Rust (unless you need something for which there’s only a C++ library, in which case you’ll probably choose C++ regardless). If it is important but not extremely important, it really depends on what your challenges are beyond performance.

3 Likes

To get the full picture one may not ignore GraalVM’s native-image and OpenJDK’s Project Panama (and also Project Valhalla).

native-image allows to compile Java bytecode to standalone executables (so you don’t even need to rewrite or modify your programs to compile under Scala-Native). Project Panama improves integration with native libraries and improves manual memory management and most probably will be included at some point in GraalVM.