Multiplatform Chaos
Tags: multiplatform, flutter, reactnative, maui
Published: 2023-09-18 16:37:53

This is a post I used to have on my website, Dotkey.dev, but I have since shut down the website. Apologies for any inaccuracies. 


## What is Multiplatform
A question that I got quite confused about when started. It is the ability to run the same code base across multiple platforms. The common pairings are:
- IOS and Android
- Mobile and Desktop
- Mobile and Web
- Mobile, Desktop and Web

## An Introduction
Multiplatform frameworks have got a little bit out of hand, haven't they?
Between Flutter, React Native and yet another JS library eying for your usage it's a bit difficult to choose.

First a list of the frameworks (At least the ones I know of):
- React Native
- Flutter
- Ionic
- Kotlin Multiplatform Mobile (KMM)
- Native Script
- Maui / Xamarin
- Tauri

I am going to be talking about **all** of them (well aside from tauri as it's in very alpha) and a bit more. I can promise I have not done enough research to make sweeping statements, but I will still be making them, so take all of this with a grain of salt. But if you are ready..

## A discussion about performance
Generally, the frameworks mentioned can be separated into two groups:

| Webview     | Seperate Engine |
| ----------- | ----------- |
| React Native | Flutter |
| Native Script | Maui / Xamarin |
| Ionic |        |

### WebView
The webview group works (generally) by shipping a browser and a communication bridge between the device and the code. Allowing for access to the phone while also being able to use code across platforms. <br/>
However, if you don't need a communication bridge (ie you don't need *easy* access to storage, camera etc) then why not use a Progressive web app (PWA)?. Wrapping a webview with a communication bridge isn't needed when you can just use a webview.

### Separate Engine
The Separate Engine group works (even more generalised) by shipping a separate renderer to the device, ie Skia. It should note that despite a separate engine, Skia is being used in a lot of places simply because there is little to no difference to native. <br/>
 
## What is 'Native'
Seriously. <br/>
The large issue with all the different multiplatform frameworks is that they largely operate in two distinct ways, both of which don't use the exact GUI toolkits for each platform (Compose, Winui etc) but really unless you code natively then you aren't going to use them… Wait what's KMM?

## Kotlin Multiplatform Mobile (KMM)
KMM is the single reason why multiplatform frameworks are so much more confusing than they were like a year ago. It is a way to share the business logic (not ui) across multiple platforms through the JVM machine and Kotlin's ability to compile with LLVM. It allows for the majority of code to be done in Kotlin with the UI done in the device's native toolkits, the best of both worlds?. <br/>
Really though, all the different framework's have an ability to switch UI themes depending on the platform you are on, so all KMM really brings to the table is allowing Android exclusive apps an easier path to IOS.

## So which one do I use?
TLDR assuming you have the ability to pick up dart, you should use Flutter. In nearly every situation it performs and is generally better than the competition. Flutter also gets around the idea that you can't get native looking apps with multiplatform with the Cupertino widget set (apple version of the ui tools). <br/>
But that's the easy answer.

There's a bit more than this ie if you hate OOP but all the frameworks have different advantages, especially if you know one language more than another or if you have an existing codebase.

<br/>
<br/>

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v3ybb1lymbug98ejip4p.png)


## What about not?
A growing community of people especially ones that dislike the UI not fitting the theme of the OS are wanting for more devs to make programs that are actually specialised to the OS and perfectly fits the user interface, at the end of the day though should we have inclusivity over quality or not.