Kotlin Multiplatform: Expectations vs. Reality for iOS and Android developers
Cross-platform technologies promise quite a lot when it comes to developing mobile apps for Android and iOS. Creating platform-specific code is not that efficient business-wise and can be quite time-consuming as well as expensive.
At the very end of a new project, apps without shared code may differ from each other – not that drastically though. However, there may still be some differences in the final product due to the different understanding of the business requirements by iOS and Android developers.
Writing a common code could be more budget-friendly and consistent – the very same logic between the two platforms is guaranteed from the very start of a multiplatform project. Some cross-platform mobile application has a native feel and look, which positively impacts user experience. Multiplatform projects are one of the couple ways for companies willing to try to release the product to market quicker at a lower cost and attract users of both Android and iOS devices.
Many cross-platform mobile technologies are trying to provide all the above. However, some of those shared code solutions turn out to be insufficient or cause problems, e.g., the UI in the mobile application does not feel entirely native. Now, is there a perfect solution for multiplatform projects, a Holy Grail of cross-platform mobile development?
Well, to be perfectly honest, there is probably no such thing. However, Kotlin Multiplatform stands out from competing solutions and seems to deliver most of its promises. Here’s something that should be remembered though – like most software development kits, Kotlin Multiplatform is perfect for some mobile applications but less ideal for others. In this two-part interview, Grzegorz, our iOS developer, and Mikołaj, who works as an Android developer, will share their experiences and knowledge regarding creating common code with Kotlin Multiplatform.
In the first part, they will focus on the differences and challenges that await Android Developers and iOS Developers in Kotlin Multiplatform projects.
Table of contents
Mikołaj: Kotlin Multiplatform – KMP for short – allows implementing a platform-native UI for both Android and iOS apps while sharing all the business logic layers beneath. This guarantees that both applications will have the same functionalities and will work pretty much the same way with fewer bugs. The cross-platform development time might not be drastically faster but should be more efficient nevertheless.
Grzegorz: Kotlin Multiplatform can also make future application maintenance much easier. In most cases, we will only have to fix a bug in one place in the shared code and thus fix it on both Android and iOS apps. We do something just once and it propagates automatically and very quickly to iOS and Android. Still, there are some challenges we must take into account.
Grzegorz: There are many challenges along the way. Kotlin Multiplatform can be used for sharing part of the code – smaller or larger, depending on the project – but not all of it. The challenges result from how certain elements are designed and how many of the key functions are placed in the common code. What is the ratio of the Kotlin shared code to the native Android code or iOS code across the entire app?
The more lines of code are in KMP, there may be more challenges to face, but also more benefits in the future. This may result in a longer development process initially – every part of the project needs to be carefully thought over.
Mikołaj: We must also keep in mind that the shared code must reconcile two completely different platforms – iOS and Android.
From a business point of view, they are just two mobile platforms. Each one requires a separate mobile application. However, when we start delving into the technical details, Android and iOS apps are vastly different inside. They work on two divergent platforms and have different assumptions that simply need to be somehow coherent in the Kotlin Multiplatform. All of this, along with possibly some unpredicted cases – not everything is always clear at the stage of gathering requirements – must be placed in the common code.
It all depends on the issue. To give you an idea, if the problem lies in the communication with the server, it can be easily fixed in one place. Also, let’s say the business requirements of the app have changed slightly. For example, the method of validating a given field must be different now. The way of displaying the error message has to be changed too. Thanks to the cross-platform development approach, such things can be implemented easier.
The challenge may arise when there are completely new features that we were not prepared for, going beyond the established business logic of the application. Then the amount of work needed to implement everything in the project may be – but does not have to be – greater than in the case of native coding.
What are the differences between using Kotlin Multiplatform for iOS developers and Android developers?
Grzegorz: It’s easier for Android developers to start using Kotlin Multiplatform. It’s the same programming language and what they write in KMP can also be used by Android. An iOS developer, however, will find it more difficult – creating a Kotlin Multiplatform mobile application will involve working in a new language, a new environment. Nevertheless, these languages are still very similar to each other and can be understood rather quickly – it’s a new language for sure, but there are analogies.
Mikołaj: From an Android developer perspective, there is not much more work to be done. Due to similarities between Kotlin and Android, integration between those two platforms is quite easy. However, Android development can be complicated – as a result, the Kotlin Multiplatform code is also more complex. There are more system constraints, more complicated queries to handle, all of which add to the complexity of the code.
Grzegorz: When coding, you often simplify some patterns. Such architecture as in KMP requires being consistent and not taking shortcuts – by doing this you can easily lead yourself to a dead end.
While considering cross-platform projects, you have to try to stay ahead of the project requirements, so you don’t have to start all over again in the worst-case scenario.
Mikołaj: Well, fixing errors from the point of iOS is a bit more difficult than with Android. Of course, there are still ways to identify a bug.
Although in the case of Kotlin, programming for iOS is more difficult, there are still patches, newer versions, plugins, and better debugging options. You should also be aware that in recent years iOS has undergone a certain transformation – the language in which it is programmed for this platform has changed. Previously, an iOS-specific code was written in Objective-C, now it’s in Swift. KMP creates Objective-C interfaces – therefore, we need to communicate with the older language in the case of programming in Swift for iOS. However, the Kotlin Multiplatform roadmap states that sometime in the future, it will also generate Swift code.
Kotlin is a fairly new technology – the roadmap also foreshadows the introduction of incremental compilation, which will significantly speed up the application development time.
Do you want to know which projects Kotlin Multiplatform is best suited for? Is it production-ready? Click here for part 2 of the interview to find out!