Kotlin multiplatform performance

This is a topic that I have raised in the past (about 1 year ago). Since then I have been doing some more development and I have now also made the code compile to Javascript in addition to the JVM and Native.

The project is a programming language (called Kap, the code is here: GitHub - lokedhs/array: Simple array language written in kotlin), and while performance isn’t a primary feature of it, it’s of course useful if it isn’t too slow. It also makes performance differences between platforms very obvious.

My benchmark is a very small Kap program that adds all numbers from 0 to some limit. The code is very short: +/⍳10000000. Here it adds all integers below 10000000, which is the highest value that is reasonable when running on JS, which is the slowest platform.

My rough benchmark results is that native (Linux) is 20 times slower than JVM, and Javascript is 100 times slower than native. These numbers are very consistent regardless of the types of tests I run, which makes sense given the fact that the time critical evaluation functions in the Kap interpreter doesn’t really change much.

In the responses to my previous questions on this topic, I was told that the numbers I see for the native version is to be expected given the heavy object allocation/deallocation I do. It was also mentioned that some work on this was going to be done in the future.

My question is now what the future looks like with regards to performance on non-JVM platforms. Should I expect there to be some significant improvement on my existing code on these platforms? This is not me demanding some incredible improvements to the compiler, but rather idle curiosity. For performance sensitive code, I’ll still be using the JVM.