JDK 8 compatibility of Kotlin

I'm not sure implicit conversions in Scala are a good alternative to extension methods. Implicits in Scala are a problem for code readability and they are also one of the things that make the Scala compiler that slow. Furthermore, you can define one implicit conversion from a type to another type, but not another time from the same type to another new type. This is because the compiler stops searching for an implicit conversion once it has found one. You don't have this problem with extension methods. This is very well described in this blog article. The article is of very good quality. You can see that the author really has a deep understanding of Scala.

Extension functions in Kotlin are on the contrary very painless and they exist in other languages as well such as Smalltalk, Objective-C (I believe also in Swift), C#, Groovy (and I think also in Ruby). The Kotlin guys might have to adapt their collection extensions to what the Oracle people have done in JDK8. I don’t think this is a big issue. If it were I would still not trade in code readability for anything else. The Groovy people had to merge their iterators and many other extention functions all over the Java class library with the ones in JDK8 as well and that has been done months ago without causing a stir. So I don’t see any big risk here and certainly not a major one. Scala implicits are on the contrary a major problem of the language. They could fix it by adding extension methods to Scala, but that they can’t do without loosing face after all the controversial discussions about implicits …

1 Like