Search code examples
spring-bootkotlinbackendvert.xweb-frameworks

Java or Kotlin for Spring Boot (And Other Web Frameworks)


I have learned both Java and Kotlin over the past year, and I want to go into backend development. I am ready to learn and explore everything I can, and I have noticed that majority [exception Ktor] of the backend frameworks I can use in Kotlin are essentially Java backend frameworks, dare I say, refactored for Kotlin. I assume this is because of the cool new features that Kotlin brings (extensions, coroutines), but if the frameworks were made with Java in mind, is there any reason why I would use the Kotlin version, beyond maybe the easier developer experience?


Solution

  • If you look at the Kotlin principles, one of them is "interoperability".

    Kotlin was built in such a way that it would be able to reuse the rich Java ecosystem to the fullest, and developers won't have to develop everything from scratch, as Go language did. So the fact that most Kotlin frameworks you see are historically Java frameworks is not a bug, but a feature of the language.

    I would ask the opposite question: is there a reason to use Java with a framework that supports Kotlin? The only reason I can see is better documentation. Most of the examples will still be in Java.

    Other than that, you'll be much more productive with Kotlin, and if the framework also has support for coroutines (I know Vert.x does, and I think Spring has support for them now as well), then also much more performant.