In term of performance, is it better to build a KM...
# multiplatform
m
In term of performance, is it better to build a KMP library from scratch using only Kotlin or rely on platform specific libraries could give a better performance (and let's say that the code complexity is the same) we can take an example of parsing library.
c
I don’t think the performance different will be very significant, since Kotlin compiles to the targets platform’s native code in either case. And if anything, for something like a parser, I think you’d find the semantics of the native library difficult to bridge to a common API without adding a lot of code around each
actual
implementation, which would probably introduce more overhead than running everything in pure Kotlin. And that’s not to mention the maintenance overhead. It’s going to be difficult to ensure the library works the same on all platforms if it’s heavily dependent upon native libraries. The library will perform more consistently and be easier to develop when everything’s done in common code. In general, it’s much more common to see libraries re-implemented in pure Kotlin, with only the most minimally-necessary bridge to the target platform implemented with expect/actual declarations, rather than attempting to build a common API among disparate libraries for each platform.