https://kotlinlang.org logo
Title
n

neerav

02/14/2023, 5:50 AM
Hello All One basic question I have. Can anyone please help me to understand ? Is
.framework
file for iOS generating in Objective-C for KMM ? If yes is there difference in terms of performance wise if we compare with Swift ?
t

Tobias

02/14/2023, 8:58 AM
Hi @neerav, do you mean if a framework is slower dann Swift Code? It depends how performant your Swift code is 😉. The "problem" is not that it is a framework or Objective C (which tends to be faster than Swift), it's how good is the translation layer from KMM's Kotlin to Objective C. I would say, If you do not build the next super computing app, you can just rely on "it's fast enough".
n

neerav

02/14/2023, 9:02 AM
Hey @Tobias I understand like KMM is generating in obj-c In general I just want to ask and understand like “framework file generated in Obj-C VS Swift” in terms of performance. and my question is not on specific swift code. But question is framework file which are generated from KMM kotlin code
t

Tobias

02/14/2023, 9:03 AM
In my understanding, the result in which objc or swift is compiled is the same.
like a bit code.
l

Landry Norris

02/14/2023, 3:32 PM
They all use LLVM to compile to machine code. The Kotlin runtime will add some overhead, since the cms gc should have more overhead than an ARC based one. Overall, I'd expect Kotlin to be somewhat slower, but have less of an effect than even having another app in the background.
n

neerav

02/14/2023, 3:41 PM
So app in KMM would raise questions on app performance specifically for iOS?
l

Landry Norris

02/14/2023, 3:44 PM
I’m currently working on an app that requires high performance in KMM for work. We see no measurable performance impact, but we also worked hard to eliminate allocations (we did the same when the code was previously C) and we don’t have exceptions in the hot path. I’d recommend benchmarking it, but don’t expect to see major drops in performance unless your code is really heavy with allocations and exceptions.
n

neerav

02/14/2023, 3:47 PM
@Landry Norris thanks for sharing info. 🙇