r/SpringBoot • u/drewsski • Jan 04 '26
Question Java vs Kotlin for Spring Boot
At my company, we have pretty extensive (15+ years) experience with Sprint Boot and the Spring Framework in general, all of it done using Java with the occasional script divergence to Groovy. This backend stack provides APIs to mobile clients, the Android portion of which is largely coded using Kotlin/Jetpack Compose. Once upon a time our Android app was coded in Java using xml views, but after getting a taste of Kotlin and compose, we never looked back. We're currently sizing up a backend migration from Spring Boot 3.x to 4.x and wondering whether to take a stab at converting some of our Gradle microservice modules to Kotlin.
The smart money bet would be not to launch a campaign on two fronts, but having cut our teeth on the Android conversion, the Spring Boot one's doesn't seem as daunting, given that we can tackle one microservice at a time. The primary concern is with serialization, since with microservices communicating via Spring Integration/ Kafka / Spring Batch, there's a good deal of that going on. Spring Boot 4 apparently took a step forward towards making Java-Kotlin serialization play nice, but wondering whether others who have both Java and Kotlin in their Spring stack have found any surprising pitfalls or gotchas.
16
u/External_Mushroom115 Jan 04 '26
Don't rewrite. Just evolve the Java codebase with Kotlin. We have been doing that for some years now and it works great. The interoperability with Java and Kotlin is good enough to have a mixed codebase micro service.
5
u/Mindless_Security744 Jan 04 '26
The only pain point I have had is my java ask that I use in Kotlin gives me some serialization issues.
I wrote java for 20 years and 8 years spring boot, many many micro services built and deployed. I started using kotlin 2 years ago with Spring boot and now I love it! Go for it!
1
u/FooBarBazQux123 Jan 04 '26
I don’t get the serialization problem, aren’t you using open standards for serialization (Avro, json. Prorobuf, etc)? Java and Kotlin interoperability is good, if you hit a wall, you can always use Java and write the rest in Kotlin.
2
u/BikingSquirrel Jan 04 '26
Been there years ago but can't remember serious issues. You obviously need to properly configure serialization (Jackson for JSON) but details also changed over time.
As others said, both can coexist, so just start writing new code in Kotlin and make sure to properly test the details.
1
u/Kingg_22_ Jan 05 '26
Start writing new code in kotlin and still using the same serialization library you use in java, you mention jackson so only install kotlin adapter, currently you can't mix libraries in the same project until you do a manual workaround. If in the future your team seeks performance, then you migrate all Jackson models to another solution, don't waste your time and money in unnecessary refactor
1
u/NeoChronos90 Jan 08 '26
Java will be here in 20 years laughing at all the incompatible versions of kotlin not being maintained anymore 😅
1
u/iamwisespirit Jan 04 '26
Just write in java
1
u/junin7 Jan 04 '26
Depends of the level of knowledge of your team about Kotlin.
0
u/[deleted] Jan 04 '26
[deleted] — view deleted comment