Kotlin Multiplatform: Evaluating Advantages and Drawbacks for Cross-Platform Development
Djordje Stanisic
October 6, 2023
5 min read
Kotlin multiplatform (KMP) is a technology that allows developers to write code in the Kotlin programming language that can be shared and used across multiple platforms, such as Android, iOS, web and desktop. This means that developers can write a single codebase in Kotlin and use it to build applications for different platforms, without the need to write separate code for each platform.
Why we think it’s good
Code Reusability Across Platforms: KMP allows developers to write code once and use it across various systems, including Android and iOS, enhancing efficiency and reducing repetition.
Efficient Testing: Utilizing KMP reduces testing time as the shared codebase ensures consistent behaviour across different platforms, simplifying the testing process.
Ease of Maintenance: The shared codebase results in fewer maintenance issues. Modifications and updates can be made fast, ensuring consistency and reducing the risk of problems.
Kotlin Language Advantages: KMP makes use of Kotlin, a statically typed language that provides all of the benefits of a native programming language. This includes better performance and increased safety.
Seamless Integration for Android Engineers: For Android engineers, KMP provides a familiar environment, making the transition to KMP smooth. The development process remains largely unchanged for Android projects.
Swift Integration for iOS: Integrating KMP into iOS projects is seamless, requiring developers to import a framework similar to any other Swift-based framework. This simplifies the adoption process and encourages cross-platform development.
Accelerated iOS Development: Proper planning and utilization of KMP can lead to significant time savings in iOS development, with potential reductions of 30-40% in development time. This efficiency stems from needing to focus primarily on the UI layer for iOS projects.
Enhanced Performance and Responsiveness: Kotlin Multiplatform promotes high performance and responsiveness by leveraging the efficiency of Kotlin as a language and the ability to optimize code for specific platforms, ensuring a smooth user experience.
Reduced Time-to-Market: By allowing the development of Android and iOS apps simultaneously with shared code, Kotlin Multiplatform significantly reduces the time-to-market for products, gaining a competitive edge in the industry.
Flexibility in Platform-Specific Implementations: While sharing core logic, Kotlin Multiplatform allows customization for platform-specific implementations, providing the flexibility needed to adapt to the unique requirements of each platform.
Using Existing Skills: Developers can use their existing Kotlin skills for both backend and shared code, maximizing productivity and making the learning curve smoother for new projects.
Support for Various Architectural Patterns: Kotlin Multiplatform supports a wide range of architectural patterns, allowing developers to choose the most suitable pattern for their project, whether it’s MVVM, MVP, or others.
Easy Third-Party Library Integration: KMP supports easy integration of third-party libraries, enhancing productivity and reducing development time by utilizing popular and tested solutions for various functionalities.
Cost-Efficiency: By reducing development efforts and resources needed for building and maintaining separate codebases, Kotlin Multiplatform offers a cost-effective solution for cross-platform app development.
Future-Proof Development: As Kotlin continues to evolve and gain traction in the industry, Kotlin Multiplatform provides a future-proof approach to app development, ensuring compatibility and support for upcoming Kotlin features and updates.
Community and Ecosystem: The growing Kotlin community and ecosystem provide a wealth of resources, tools, and support for Kotlin Multiplatform, making it easier for developers to adopt and succeed with this technology.
Not everything is shared across platforms
100% shared:
Data layer: Repository classes and data sources, encompassing data retrieval, storage, and processing, which can be used universally regardless of technology or environment.
Business logic: Use cases, interactors, utility functions, algorithms, and any domain-specific logic. The business logic is the core of the application and is usually designed to be platform-independent. It encapsulates the application’s rules and operations.
Partially shared:
Presentation logic: ViewModel (for Android) or Presenters (for iOS) and related logic that governs the interaction between the UI and the business logic. While the core presentation logic can be shared, some platform-specific adaptations might be necessary to cater to the different UI patterns and behaviours on each platform.
Not shared:
UI logic: Activities, fragments, Views (for Android), and View Controllers (for iOS) are platform-specific components that handle the user interface. These components are specific to each platform and need to be implemented separately for Android and iOS. They interpret the shared presentation logic to create the platform-specific UI experience.
Note: There is a UI framework called Compose Multiplatform that will enable us to make one UI logic for multiple platforms but is still in alpha. Until this framework becomes stable we will not consider UI logic shared between platforms.
Downsides of KMP
Early-stage development: KMP was in the alpha stage in 2019, and it only reached the beta stage in October 2022. This means anticipating potentially non-backward compatible changes in the near future, adding to development considerations.
Compatibility challenges with iOS: iOS has a stricter memory model, causing potential crashes on iPhones. Kotlin objects need to be “frozen” to ensure immutability before passing them to the iOS thread. Although Kotlin Native’s new memory model aims to address these issues, its effectiveness remains untested.
Learning curve for developers:
iOS developers need to learn Kotlin to effectively use KMP.
Android developers must familiarize themselves with iOS/Xcode to ensure the shared code functions correctly on iOS.
Recruitment difficulties: Finding professionals familiar with KMP is challenging, especially iOS developers willing to learn. KMP suffers from the historically negative reputation of cross-platform solutions within the iOS ecosystem.
Inferior iOS developer experience: Xcode integration relies on unofficial plugins and build scripts. Engineers need to keep both Xcode and Android Studio open simultaneously for development. Apple has not shown official support for KMP, adding to the difficulties.
Compatibility and debugging hurdles:
Kotlin builds in Objective-C and currently lacks Swift support, making debugging more challenging for developers.
Certain important features like generics, Coroutines, Codable, Default argument, and Swift enums are not supported on iOS.
Limited community and support: The KMP community is relatively small, relying heavily on a few companies like Jetbrains and Touchlab for resources and libraries, limiting the support available for developers.
Competition from Flutter: Google’s cross-platform solution, Flutter, presents strong competition. It has become the official technology for apps on their upcoming mobile OS, Fuchsia, potentially overshadowing KMP in the cross-platform landscape.
10 famous companies that use Kotlin Multiplatform
Netflix: Netflix, a popular OTT platform, utilized Kotlin to rebuild the UI player in their Android application.
Autodesk: Autodesk, a multinational software corporation, adopted Kotlin for its compatibility with iOS and Android, eliminating the need for Java native interface.
Quizlet: Kotlin Multiplatform powers the Quizlet app, a global learning platform with 100 million active installs, offering engaging study tools for effective learning.
Cash App: Cash App, a mobile payment service by Square, Inc., embraced Kotlin for seamless money transfers among users through their mobile app.
Baidu: Baidu, a leading AI company and the world’s largest Chinese-language search engine, leveraged Kotlin Multiplatform to unify business logic in their Wonder App and maintain a consistent user experience.
9GAG: 9GAG transitioned to Kotlin Multiplatform after exploring Flutter and React Native, leading to faster feature development and a consistent user experience.
Vmware: VMware, an American cloud computing and virtualization technology company, adopted Kotlin Multiplatform as their cross-platform strategy for mobile applications, making it their default framework of choice.
Trello: Trello, a project management application, built its Android application using Kotlin due to its strong interoperability with Java.
Philips: Philips, a well-known multinational corporation, experienced faster feature implementation and improved team collaboration between Android and iOS developers using Kotlin Multiplatform.
Ice Rock: Ice Rock, an outsourcing company providing mobile and backend solutions, utilizes Kotlin Multiplatform Mobile to develop applications for various industries and market segments.
When did you realize it was time for changes in your life? Those moments when you just knew it was time to shake things up to make your future align with the vision you’ve always had? That’s what we’re diving into in this blog. Four years ago, Skenit was born out of a need to […]
Mobile app development is buzzing with excitement after the big announcements at Google I/O 2024. The latest updates for Flutter and Dart are here, bringing new features and improvements that promise to make multi-platform app development even better. Flutter 3.22: What’s New? The newest version, Flutter 3.22, brings exciting enhancements. Flutter continues to be a […]