12 ms·
I you really want the best possible performance you absolutely can program in Scala with little to no performance penalty over Java. In fact, in exactly the sam
by Quekid5 5y ago
I you really want the best possible performance you absolutely can program in Scala with little to no performance penalty over Java. In fact, in exactly the same way you can program in Java and still remain competitive with code written in C/C++ (except the typical differential isn't as drastic).
You still have access to "raw" JVM arrays, mutability, etc.
The difference is that you can choose to just restrict the 'ugly' code to your performance bottlenecks and code everything else at a higher level. This gets even better in Scala 3 with opaque types, etc.
- bitcharmer 5y agoSomehow the landscape of low-latency Java doesn't include other JVM languages so I don't think it's easy to achieve with Scala or Kotlin.
- Quekid5 5y agoIt's not some great mystery: Very few people are doing low-latency in Java in the first place, and all of the people who are have probably been doing it for a long time (in Java) already so there's a non-trivial cost to switching from Java to $OTHER_LANG. It has nothing to do with how easy it is to achieve the performance if you really want to. Well, OK, I might grant that there are a couple of very minor things that kind of work against you in e.g. Scala, namely lack of a native 'for-which-is-a-thinly-veiled-while-loop' and such, but that can be worked around with e.g. spire's cfor or just using while loops. Compared to the amount of effort to get anything-on-JVM working well in a low-latency environment in the first place, these obstacles are all trivial.