1.15.2 Using kotlin

Discussion in 'Spigot Plugin Development' started by Xocky, Feb 3, 2020.

  1. Can you use kotlin for spigot plugins? Is it in any way better than java for it?
     
  2. Yes and depends.
     
  3. 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".
     
  4. I reduced my Kotlin dependencies to 700KB. In the past I had around 4 MB of Kotlin dependencies.
     
  5. 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.
     
  6. If you're shading Kotlin reflect, Kotlin exposed and whatever else you may be using, it can get towards the 10MB side
     
  7. 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 :)
     
    #7 garbagemule, Feb 3, 2020
    Last edited: Feb 3, 2020