|Android KTX - Kotlin Extensions|
|Written by Mike James|
|Wednesday, 07 February 2018|
Google has just announced Android KTX, a library of Kotlin extensions that are designed to make Android easier to program using the latest first class Android Language. It at least reveals how serious Google is about Kotlin for Android.
KTX is a strange beast. It isn't part of the Android Framework and it has to be included as a separate library to make use of it.:
"Today, we are announcing the preview of Android KTX - a set of extensions designed to make writing Kotlin code for Android more concise, idiomatic, and pleasant. Android KTX provides a nice API layer on top of both Android framework and Support Library to make writing your Kotlin code more natural."
It isn't being released as production quality code as yet, but given its nature it seems safe enough to try it out. If an extension isn't doing what you want you can simply drop back to the Framework. The only warning is that, given it is a preview, it could change.
The team is so keen on Kotlin that they have produced a video and called it Introducing Android KTX: Even Sweeter Kotlin Development for Android:
The final "Kotlin is here to stay and we have big plans for it" is quite an eye opener if you are planning to stay with Java.
It is true that most of the extensions are simply syntactic sugar and yes you could dismiss them on these grounds, but they do make programming easier. Many of the changes could have been made directly to the Framework rather than as extensions but extensions mean you can take it or leave it.
KTX also introduces the androidx namespace:
"This is a new package name prefix that we will be using in future versions of Android Support Library. We hope the division between
It also raises the question of how much overhead is involved in using KTX, both in terms of the included libraries and the extensions as static methods.
It is interesting to see how many of the improvements could have been added to Java with a little more effort and Java 8 support. What is certain is that the Android team seems to love Kotlin and this probably means that Java is going to get less attention in the future.
Mike James is the author of Android Programming In Kotlin: Starting with an App and The Programmer's Guide To Kotlin
Summer SALE Kindle 9.99 Paperback $10 off!!
or email your comment to: firstname.lastname@example.org
|Last Updated ( Wednesday, 07 February 2018 )|