DEV Community


Discussion on: Q: How Much of "the Kotlin Way" Is the Right Way?

tunji_d profile image

Nitpicking your example, the differences between the two methods is hardly down to intrinsic ability of the languages. The Kotlin version is just a wrapper around the Java one, and a utility class can be written in Java to the same end.

The Kotlin KTX libraries are really more or less apache utils for Android, and would be just as useful written if written in Java, the advantage Kotlin offers in this regard is solely the benefit of extension methods instead of static utility functions which is more of an idiomatic plus than a functional one.

sleepyfran profile image
Fran González

You're right, however I don't think we'd have any of these libraries in Java since that's not an idiomatic way of writing Java.

Ultimately what I meant is that what Kotlin brought to the JVM was another way of writing code that was compatible with the huge amount of libraries that exists in the ecosystem; and of course when people realised that they can write libraries taking advantage of some features of the language that makes thing easier, they'd do it.

Maybe a better example of this are Anko or Koin since both are libraries that feature a DSL built on top of Kotlin.