How is KMP / CMP compared to Electron for desktop ...
# multiplatform
p
How is KMP / CMP compared to Electron for desktop apps ?
j
Significantly not-Electron, which is a big win for a lot of people 😛 Given Electron is just a runtime for running <thing in JS> in a window, what exactly is your comparison here?
👆 1
p
Haha not-Electron is definitely a big win for sure! I am actually thinking what to go for, for my app. It’s a simple file manager for now. The thing is Electron chugs memory like crazy. Also it is janky with many an apps.
h
What exactly do you mean? Kotlin/Native produces native code. CMP uses Kotlin/JVM, so you need a JVM. React native produces JS that needs a JS interpreter.
j
I think the footprint people associate with Electron isn't really a problem with Electron - to an extent Objectively speaking, you should probably pick one or more UI frameworks and whatnot for JS and compare the whole stack. Subjectively speaking, KMP all-in K
p
@hfhbd it uses jvm on all platforms ? I would like to target macos firstly. Will the jvm be packaged in the app.. or how will it run.
@Jack Boswell why do you say it isn’t really a problem with Electron ? KMP all-in.. as in for all platforms ?
h
KMP != CMP
💯 1
Compose for Desktop uses Kotlin/JVM on all platforms
But you can use Kotlin Native with another UI framework, like SwiftUI on macOS
p
Okay, so CMP is built atop of KMP.
Damn this jvm thing now suddenly confused me 😞
I thought it would be simple coding like in KMP 😅 and running it on MacOS
Or is it ?
j
All Electron is is a Chromium engine with a bit of Node JS sprinkled in. If your Electron app is using 1GB+, it's not Electron using that, it's your app that is running within the Chromium engine As an example - Chrome will show you memory usage per tab nowadays, you can see different levels of memory usage across different websites (the rough equivalent of an Electron app)
👍 1
YouTube might use multiple GB. DuckDuckGo homepage might use a few MB
p
Got it @Jack Boswell Actually had started with Kotlin for mobile apps
hence thought to use it for Desktop apps too
So where does Kotlin native sit ?
And what effect will jvm have on the apps ?
How does Flutter compare for desktop ?
j
When you use Kotlin for Android, you are compiling to Kotlin/JVM, targeting the Android SDK (I'm probably missing details, please correct me if I'm wrong) When you use Kotlin for iOS, you are compiling to Kotlin/Native, targeting Apple's SDK Ecosystems that Kotlin can target are generally based on platforms. Different Kotlin libraries support a subset of these platforms
Kotlin/JVM can run on Android (as an Android target), and desktop. Compose Multiplatform supports Android and Desktop via JVM (and some Android specific bits) It also supports iOS via Kotlin/Native, but specifically for iOS
So you can build all your business logic targeting everything, but if you want to build your UI you will be limited to Android, iOS, Web via WASM, Desktop (Windows, Mac, Linux) via JVM
During development, you just get a run button
For publishing binaries, I do believe you can configure whether you bundle a JRE on desktop (Android, iOS and web don't need one)
You could check it out pretty quick by creating a new project and clicking run 🤔