Interested in programming JavaFX in Kotlin? Here’s what you need to know to write JavaFX code that is so much better than anything you can write in Java.
What is Kotlin?
Kotlin is a multi-purpose programming language that runs in the JVM. In many ways, it’s what Java would have been had it been designed 20 years later.
Kotlin code is much more concise than the equivalent Java. It has native features that address many of the gripes that programmers have about Java, including the following:
- Null safety is built-in.
- Fields are implemented as
Propertiesthat include default (but configurable) getters and setters.
- The ability to add methods and fields to classes without formally extending them.
- Semicolons are optional!
- Automatic inference of data types when declaring Variables
- Default values in method signatures, reducing the need to overload methods.
Kotlin is 100% compatible with Java, so you can freely use any libraries that are written in or for Java. With a few caveats, you can also call all of you Kotlin code from Java. You can even mix Kotlin in with Java in the same project!
Of course, Kotlin works really well with JavaFX. In fact, JavaFX is way better with Kotlin than it is with Java.
I’ve written a few articles about Kotlin, you can find them here:
Need to understand a Kotlin program, but you only know Java? This article should give you everything you need to know to get started.
Kotlin has been described as, “The language that Java would have been if it had been designed 25 years later”. It’s starting to pick up popularity, and has had a boost from being endorsed by Google for Android development.But you’re not an Android developer, so should you learn, and use, Kotlin?
An approach to implementing the JavaFX Property “bean” structure for observable objects in an idiomatic Kotlin fashion.