Reviving JTransc to use with KorGE

Oct 03 2020

It has been a while since the last time I updated JTransc (almost 3 years since the last update!). Once Kotlin-Multiplatform and Kotlin-Native started to appear, I migrated all the code to that. Dropped all reflection support and sticked to what was available. Since then, lots of things happened, and Kotlin improved a lot.

Problems with Kotlin Multiplatform

Still, Kotlin-Native/Multiplatform is a bit problematic in terms of multithreading, compilation times, IDE memory and response times while editing. Releasing new versions of the libraries or generating a native executable also take a lot of time, lot of size and artifacts. And since it uses LLVM under the hood without an intermediate C/C++ representation, I cannot target platforms that are not supported by Kotlin/Native. Runtime performance of Kotlin/Native is still not very good.

JTransc

The good things about JTransc is that it generates source code for several languages that can be compiled or executed with any compiler or interpreter even those unsupported. So I can target C#, JS, Dart and C++. And target any platform I want natively. In the case of C++, it will work as long as the compiler supports the c++11 standard.

Updating to lastest Kotlin and Gradle versions

I have updated JTransc to support the latest version of Kotlin and Gradle. The older version didnt’t detect dependencies with the new “implementation”/“api” configurations. On master that works properly.

New Portable Precise C++ GC

I have been a couple of days working on a new portable and precise C++-based GC. From the first version I think the performance has improved something around 4x~5x! For now it is a stop-the-world non-concurrent mark and sweep GC with a custom memory allocator/checker for the stack.

I’m a newbie to implementing GCs, though I have been reading about them for years, also there was a lot of time since I used C++, so I will write a separate blog post for this.

KorGE

I will update KorGE and Korlibs to support JTransc again in the coming months after 2.0 is released and will implement KorGE stuff on top of SDL and OpenGL on JTRansc to target any platform supporting SDL/OpenGL including videogame consoles.

Stay tuned!

Performance comparison

I have converted most of the tests of the JTRansc benchmark into pure Multiplatform Kotlin to measure performance.

Notes: JS IR is usually faster, except for StringBuilding, but somehow has a problem with char arrays. Once JTransc relooper is shipped, the performance should be similar.

Comparing Kotlin/Native (Kotlin 1.4.10) vs JTransc C++, JTransc C++ performs allocations much faster (maybe 2x as fast with the new GC), and have similar performance on arithmetic.