Kotlin Multiplatform: Evaluating Advantages and Drawbacks for Cross-Platform Development

author avatar

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:

  1. Data layer: Repository classes and data sources, encompassing data retrieval, storage, and processing, which can be used universally regardless of technology or environment.
  2. 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:

  1. 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:

  1. 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

  1. Netflix: Netflix, a popular OTT platform, utilized Kotlin to rebuild the UI player in their Android application.
  2. Autodesk: Autodesk, a multinational software corporation, adopted Kotlin for its compatibility with iOS and Android, eliminating the need for Java native interface.
  3. Quizlet: Kotlin Multiplatform powers the Quizlet app, a global learning platform with 100 million active installs, offering engaging study tools for effective learning.
  4. Cash App: Cash App, a mobile payment service by Square, Inc., embraced Kotlin for seamless money transfers among users through their mobile app.
  5. 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.
  6. 9GAG: 9GAG transitioned to Kotlin Multiplatform after exploring Flutter and React Native, leading to faster feature development and a consistent user experience.
  7. 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.
  8. Trello: Trello, a project management application, built its Android application using Kotlin due to its strong interoperability with Java.
  9. Philips: Philips, a well-known multinational corporation, experienced faster feature implementation and improved team collaboration between Android and iOS developers using Kotlin Multiplatform.
  10. 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.

Care to share?


Unveiling the Dev Journey: Experiences in Product vs. Outsourcing Development

Business

Unveiling the Dev Journey: Experiences in Product vs. Outsourcing Development

In the dynamic landscape of the Serbian IT community, our team finds itself at the intersection of two compelling narratives: outsourcing and product development. Beyond being an outsourcing hub, Serbia is home to numerous companies that have crafted their successful products, adding a unique vibrancy to the IT community.  Right now, some of our team […]

5 Years of Crystal Pigeon: A Journey of Friendship, Challenges, and Success

Uncategorized

5 Years of Crystal Pigeon: A Journey of Friendship, Challenges, and Success

Time flies, doesn’t it? You’ve probably heard this phrase quite often, especially in the business world. It’s a sentiment we’ve been expressing a lot in the past month as we celebrated the fifth birthday of Crystal Pigeon. We won’t talk too much on this topic, but we feel the need to express our gratitude and […]