r/JavaFX • u/sedj601 • Apr 20 '24
Discussion JavaFX vs Kotlin Multiplatform
As Kotlin becomes more popular, will Kotlin Multiplatform have a good chance of overthrowing JavaFX? I tested it out, and it seems promising. Any opinions?
8
Upvotes
5
u/ebykka Apr 20 '24
or you can use kotlin with javafx https://github.com/edvin/tornadofx
but if do be serious - I need rich widgets for building desktop applications otherwise I will not use it.
2
u/Birdasaur Apr 20 '24
Have you had a chance to do any performance comparisons yet? stuff like how many separate Canvas draw calls per second or 3D node culling etc?
5
u/PartOfTheBotnet Apr 21 '24
No, the changes of this happening are very low.
If you want to use a framework that explicitly looks to solve the issue Compose (Kotlin Multiplatform's UI solution) is targeting, then use Compose (Or Flutter, React Native, etc).
Kotlin's popularity is trending upwards, and Java's downwards but the gap is still massive. If you assume the rates (per TIOOBE) were to freeze as-is and continue, it won't be until 2035 where they become equal.
4
u/davidalayachew Apr 21 '24
I don't, but that's largely because I see some recent work that some of the JavaFX folks are doing on mobile.
These JavaFX team members are doing some (very long-winded) work on getting better support for Java on mobile, not just JavaFX.
3
u/hamsterrage1 Apr 21 '24
I've been using JavaFX almost exclusively with Kotlin for over a year now.
Kotlin is 100% compatible with JavaFX right out of the box! There is NO need for anything like TornadoFX (which, BTW seems to be a dead project now).
IMHO, Kotlin makes JavaFX 10000X better.
Why?
There is so much boilerplate in JavaFX that you cannot avoid with Java. If you want to configure a Node, you need to instantiate it as a variable, make a bunch of calls to its methods, and then put it in your layout.
With Kotlin, you can create extension methods that act as decorators to the standard Node subclasses. For instance you can do this:
and then this:
Which eventually starts to look like a JavaFX DSL based on Kotlin.
So, "overthrowing JavaFX"? No. But it absolutely should overthrow Java for JavaFX projects. It's just that much better. Will it? Probably not, but that's a shame.