:zap::zap::zap: ️Question about performance on iOS...
# ios
m
️Question about performance on iOS Given I use purely KMP (no CMP) on iOS. Ui is in SwiftUi, then from my understanding all the Kotlin codes gets compiled into native binaries, as does Objective C. 1. there should be no performance impact if my business/data layer are in Kotlin or Objective C, right? 2. there should also be no battery impact kmp vs objective c, Or am i missing something? People who already use KMP in production: how do you rate performance?
1
a
We've found performance to be better than expected, especially if you take advantage of coroutines between the model and ui layers. We did exactly what you describe for years. We built an entire cannabis delivery and POS company (think Uber, but a lot more compliance, restrictions, and pains in the rear) in Kotlin with mobile apps for drivers, consumers, and businesses that all perform very well compared to most native apps. We've written apps in Swift fully before and if both are done right you shouldn't really be able to tell which is Swift and which is KMP.
m
Thanks @Anonymike that is very good to hear! So you never got complaints for excessive battery usage due to Ktor or other Kotlin I/O libs running on iOS?
a
Not at all. That said, we are incredibly respectful of user privacy and background tasks so we don't try to do a lot. We don't have background tracking services or anything like that. We do load thousands of images of cannabis strains dynamically resized by the server and menus with local search functionality for example and have no trouble with those. The navigation system for the driver app is one native component for example that we wrap with compose. If you have any other questions please feel free to ask. The release size is less than 19.7 MB for the consumer app as listed on the app store.
Oh and we don't use web views for anything. It is all native UI.
j
There will be some impact since Kotlin is a higher-level language than Obj-C. It’s garbage collected and it doesn’t support stack-based objects. I’d expect higher memory usage and some pauses for GC. But this probably won’t be noticeable unless you’re doing a lot of work in the app.
a
@Jens Alfke has a great point, though that cannabis app will load a menu of a thousand products with 1 to 4 variants (pricing for weights etc.) each and render it with local searching quite well. Like most things in SwiftUI though, if you're not careful about layouts and let them get too fluid, scrolling that many items will get jittery.