Want a better Minecraft server? Read about SpigotMC here!
Separate names with a comma.
Discussion in 'Spigot Plugin Development' started by Xocky, Feb 3, 2020.
Can you use kotlin for spigot plugins? Is it in any way better than java for it?
Yes and depends.
You can use Kotlin just fine
But know that you will need to get the runtime and standard library mappings bundled up in the plugin jar unless you can guarantee that they are on the classpath at runtime. You're looking at a couple of megabytes of extra files, IIRC.
Edit: Like ysl says, whether or not it's better depends on how you define "better".
I reduced my Kotlin dependencies to 700KB. In the past I had around 4 MB of Kotlin dependencies.
I think it comes down to which parts of the standard library you're using. You can definitely apply some form of tree shaking to cut out the parts you're not using.
4 MB seems like quite a lot, though. It probably also depends on which version of Kotlin you're using.
If you're shading Kotlin reflect, Kotlin exposed and whatever else you may be using, it can get towards the 10MB side
Reflect and Exposed are both arguably situational, and Exposed especially is not different from non-Kotlin dependencies since it isn't essential. I think it's fair to say that you'll want runtime and standard library (if only a subset) in every project. It's worth noting because of the 5 MB limit