React Native vs Kotlin Multiplatform. What Will the Future of Multiplatform Development Look Like?
The cross-platform code sharing promise is undoubtedly the most tempting feature of this technology. Despite being a very popular choice, React Native is not a Holy Grail and has its limitations. There are companies which already decided to change their mobile tech stack radically and switch to platform-native development for their existing apps.
There is however a new solution available which aims to allow implementing scalable, multiplatform projects and promises to eliminate React Native's issues. Kotlin Multiplatform allows targeting not only iOS and Android, but also backend, web frontend, and desktop platforms at the same time, allowing you to compile the shared codebase into platform-specific executable code without any bridges.
This article will compare and contrast the capabilities of the well-adopted and already mature React Native technology with the new experimental Kotlin language feature called Kotlin Multiplatform in order to find out what use cases each of them better is better suited for.
React Native
React Native, a stable and popular framework created by Facebook, is a popular choice for mobile app development. It allows building mobile apps for Android and iOS in JavaScript. React Native lets us compose UI components in JS code which is then translated into native platform-specific components.
The big advantage of React Native is the big community and wide adoption. There are plenty of external libraries and custom, open source components available. All this makes it convenient choice for rapid prototyping and quick MVPs.
What’s the main drawback of this JavaScript-powered framework? Probably JavaScript itself, whose limitations make React Native applications somewhat harder to scale and less flexible compared to other technologies.
Main features
-
UI code shared between iOS and Android
-
Powered by JavaScript
-
Live reload of the app's UI
Pros
-
A great number of open source libraries
-
Big community
-
Reusable UI code
-
Does not require a big dev team
-
Good for small mobile MVP projects
Cons
-
Low security and memory management issues due to JavaScript-based libraries
-
Bridged communication between JS and native platforms
-
Performance issues
-
Limited to iOS and Android
Kotlin Multiplatform
Since Kotlin as a language for Android app development started being officially supported by Google, it has been constantly growing. Kotlin is becoming very popular among developers because of its cleanness and development speed. It was even chosen as the second most loved programming language in the Stack Overflow Developer Survey in 2018. Although this new language itself is currently the most popular among Android developers, it can also be used on the backend and frontend sides. Moreover, it can be compiled and run natively on iOS, MacOS, Linux, Windows, WebAssembly, and even embedded systems, like STM32.
Starting with Kotlin 1.2, JetBrains released an experimental language feature called Kotlin Multiplatform. Its promise is to write the business logic components once and reuse them on all platforms - it can be compiled to including JVM, Android, JavaScript, iOS, Linux, Windows, Mac and embedded systems. The biggest advantage over other multiplatform solutions like React Native is that Kotlin code can seamlessly cooperate with other native components, like the UI layer or platform-specific code. Moreover, it’s possible to share the logic with a backend or whatever other applications you might have.
Main features
-
Multiplatform development of business logic code
-
A great number of compilation targets - Android, JVM, native: iOS, Windows, Linux, embedded platforms, and more
-
Modern language - safe, concise syntax, efficient multiplatform async framework, and more
Pros
-
Compilation to native platform-specific executable artifacts
-
No bridges between shared code and native platforms
-
Best possible performance
-
Possibility to share code between many platforms: Android, JVM, JS, native (iOS, x86, STM32, and more)
-
Suitable for well-crafted, scalable projects, not just for mobile apps
Cons
-
Still in an experimental state
-
Limited number of available libraries
-
Usually requires a bigger team of devs working together
-
Less suitable for fast MVPs and prototypes
What will the future look like?
React Native is losing its dominance in the mobile area, which is probably caused by the latest release of Flutter - another multiplatform UI framework by Google. The future of both is still unknown, although it seems the hype for Flutter has already started.
Is there a place for Kotlin Multiplatform then?
It seems so. It turns out that it could be a great technology to be integrated into the mobile apps along with Flutter. That’s because Flutter allows separating the UI layer from the business logic effectively, and Kotlin Multiplatform provides an exceptionally good way to share business logic code between multiple platforms.
There is also an experimental Google project under development - Hummingbird. It aims to allow the reuse of Flutter UI code not only on mobile platforms, but also on the web frontend. And that’s the web frontend where Kotlin Multiplatform has the potential to be used as well. The Flutter for Web beta is speculated to be announced around Google I/O 2019.
Are we going to be able to develop multiplatform apps for the mobile and web platforms at the same time? It seems there is going to be such an option available. Developing apps with Kotlin Multiplatform and Flutter would require the use of two languages - Kotlin and Dart. However, from the developer perspective, both languages are friendly. Although there are already basic Kotlin Multiplatform libraries available like the SQLDelight database, the Ktor REST API client or Kissme, a secure key-value storage solution, the adoption rate of Kotlin Multiplatform will highly depend on the development of new ones.
Is this the end of React Native? Probably not. As a mature technology, it will still be great choice for iOS and Android apps - especially for rapid MVP development and fast prototyping. However, it seems that it is going to be an interesting year and a new multiplatform development standard is just around the corner. Stay tuned and let’s see what this year brings!