u/snowe2010in r/Kotlin • Recommends
On “What are the idiomatic differences between Kotlin libraries and Java libraries? Is there a Kotlin way of creating library APIs?”
#For a Kotlin Library:
##Calling from Kotlin:
###Advantages:
* named parameters
* no ugly conversions between things like KClass and Class
##Calling from Java:
###Disadvantages:
* no Kotlin features
* unless the library is prepared for Java users (`@JvmStatic`) you might have trouble calling the library
* dependencies on Kotlin even though you aren't using Kotlin
#For a Java Library:
##Calling from Kotlin:
###Advantages:
* you get null safety on many existing libraries, due to use of JSR-305 nullability annotations
* you can convert between types like KClass and Class pretty easily
### Disadvantages:
* Passing lambdas is more difficult in some cases
* no support for named parame…