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.

kotlinlogo

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 android.* and androidx.* makes it more obvious which APIs are bundled with the platform, and which are static libraries for app developers that work across different versions of Android."

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

 

coverKotlinsmall

cover

 

More Information

Introducing Android KTX: Even Sweeter Kotlin Development for Android

Related Articles

Android Programming In Kotlin: Layouts and Autonaming Components

The Programmers Guide To Kotlin - Iterators, Sequences & Ranges

Kotlin Begins Its Takeover Of Android

The Future Development Of Kotlin

Kotlin - New Language For Android

Kotlin - another Java alternative?

kotlinAndroid

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

 

Banner


C23 ISO Standard Is Here But You Probably Won't Read It
06/11/2024

At last ISO C23 has been published, but at $250 you probably aren't going to read it. Can we really tolerate this sort of profiteering on the work of others? This is worse than academic publishing!



Google Intensive AI Course - Free On Kaggle
05/11/2024

Google is offering a 5-Day Gen AI Intensive Course designed to equip data scientists with the knowledge and skills to tackle generative AI projects with confidence. It runs on the Kaggle platform from [ ... ]


More News

espbook

 

Comments




or email your comment to: comments@i-programmer.info

 

Last Updated ( Wednesday, 07 February 2018 )