The impact Kotlin had at Crunch in just one year

Why we started with Kotlin

Interoperability with Java

Making Every Line Count

Coolness

IDE support

Community interest

How we did it

Our refactoring approach:

  • Apply IntelliJ “Convert Java File to Kotlin File” to the selected package(s)
  • Manually fix any conversion errors
  • Perform an IntelliJ code inspection and apply (95% of) Kotlin recommendations
  • Check all tests
  • Manually inspect all code: is it as clean and concise as we would hope?
  • Repeat refactor for tests
  • Migrate Mockito to MockK & springmockk, replace AssertJ with Strikt.

The Kotlin Way:

Data classes:

Team Ownership:

How it worked out

Code reduction:

  • Around 10% for the tightest, most polished Java codebases
  • Around 20% for flabbier specimens
  • As much as 40% for projects that are domain/DTO/entity-heavy, i.e. projects that manage domains and largely move data around.

You’re rewriting working code?

Kotlin APIs:

Conclusion

  • Roughly 10% of our microservices are Kotlin only
  • Roughly 30% are mixed Kotlin and Java. Of these, generally, about 10–15% of the overall lines of code are Kotlin, though this figure understates Kotlin’s impact within the service
  • The majority of our microservices are still Java only, though this may change.
  • Higher expectations about code quality
  • More options to solve problems in an elegant way
  • Almost inevitably, less code to maintain
  • A restatement of developer freedom, and hopefully a renewal of developer enthusiasm.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store