What are the differences between Kotlin Multiplatform & Compose Multiplatform?

I installed IntelliJ on my Mac. I have a book on Kotlin programming. I’m learning Kotlin!

I’ve explored different programming languages - BASIC(before it became Visual Basic), Visual Basic, Turbo Pascal, & Java. Java is so verbose.

On Basic, I did some programs that plotted parametric equations. That’s what I’m primarily interested in doing - graphics programs like parametric equations, fractals, trig functions.

I read online that Java Swing & AWT are obsolete. Yet a website stated that they are not obsolete. Java FX is so verbose. Kotlin has math libraries that I can import.

So, I want to do GUI desktop apps.

It seems to me, based on what I’ve seen online & watched on YouTube, that Kotlin Multifunction & Compose Multifunction both do the same thing. Do they?

Not exactly.

I assume you mean Kotlin Multiplatform and not Kotlin Multifunction.

Kotlin Multiplatform allows you to compile your Kotlin code to target different operating systems.

This is my rough understanding of how everything works. When you compile Kotlin, you have the following options:

  • Compile Kotlin down to JVM bytecode, which can run on a JVM. Your code can then be run anywhere that can run a JVM. (Windows, Mac, Linux, Android?)
  • Compile Kotlin down to JavaScript.
  • Compile Kotlin down to native machine code for Windows, Mac, or Linux. This produces a native binary that can be run without any external dependencies like a JVM.
  • Compile down to native code for Android/iOS

Kotlin Multiplatform, as far as I understand, is a tool for configuring your Kotlin project to compile the code to multiple platforms.

Tbh, if you’re just going to write code and run it on your Mac, and maybe Windows and Linux as well, just compile down to Java bytecode and run it on the JVM. That’s the easiest solution, and you don’t need to use Multiplatform. I haven’t used Multiplatform myself, but from other posts I’ve seen on this forum, I think it has a lot of issues and isn’t documented super well. I think that Kotlin is primarily used to compile down to Java bytecode, which means there’s a lot of information about there about how to do it.

Compose is a GUI library/framework written in Kotlin. So with Compose, you have the same compilation options as you do with regular Kotlin code; compile it down to JVM, compile it natively, compile it for smart phones, etc. etc.

I hope that kind of clears it up. :slight_smile:

1 Like

Sorry about the typo.

I have a friend who has a Windows computer. I don’t know if he has Java installed or not. If he doesn’t have Java installed, I reckon that Windows or the Kotlin app will complain. Do I need to create a JAR if I want to send my app to a friend?

Does Compose create the windows & buttons & text boxes & one has to add the code? Like, for instance, I add a button & the code to do whatever I want to happen when the button is clicked. I remember that from Visual Basic. That’s what I want to be able to do.

A JAR file only helps if the user has Java installed.

When it comes to Java, there’s two parts; the JRE, and the JDK. The JRE is the Java Runtime Environment. This includes the JVM (Java Virtual Machine), the core Java code, and probably some other stuff. The JDK is the Java Development Kit, and the JDK includes everything the JRE has plus extras, like the compiler.

End users only need the JRE to run Java programs. It’s usually pretty easy to install it. You need the JRE (or JDK) to run compiled Java code, whether that’s .class files, or a .jar file. The JDK is for developers, as the name suggests. :slight_smile:

If you’re making a program for your friend, if you compile it down to a .jar file, then your friend would need to have Java installed, yes. If they don’t have Java installed and don’t want to install it, then you would need to create a native binary using Kotlin Native (or GraalVM), to create a Windows executable.

For Compose, I haven’t used it much, but yeah, it creates the windows and buttons and text boxes and stuff. Compose is like the JavaScript framework React, if you’ve used that? Compose is entirely code, though, so there’s no visual designer, which I think Visual Basic has. Compose does have a plugin that can give you previews of what your code will look like as a GUI, but it’s all written in code. Compose code would look like this:

fun main() = application {
    Row {
        Label("This is my cool app!")
        Button("Press the button") {
            // do something when clicked
        }
    }
}
1 Like

The other day I was on a Windows forum asking questions about dotnet. The AI babbled on about installing XCODE & VS Code. It talked about backends, shared libraries & on & on & on! It mentioned that I need XCODE to submit the app to Apple for approval. Apparently, I need to switch back & forth between XCODE & VS Code. I don’t want to learn XCODE & VS Code & C# & switch back & forth.

If I were to choose Kotlin Multiplatform would I also need to install XCODE to submit the app to Apple for approval?

Which would be better for me - Kotlin Multiplatform or Kotlin Native?

I don’t know anything about submitting Kotlin apps to the app store, sorry.

Regarding multiplatform vs native, I think it depends if you want to target mobile devices. As far as I understand, Kotlin Native compiles Kotlin code down to native machine code for Windows. (And maybe also for Mac and Linux) Where as I think Kotlin Multiplatform compiles down to the JVM, and also Android, Kotlin, and JavaScript. But I’m not 100% certain on that.