DEV Community

Discussion on: Kotlin - The Good, the Bad and the Ugly

Collapse
 
defiance profile image
Defiance Black • Edited

I have no experiences with Kotlin but it interests me as a gateway into Android apps. Is there a short story to tell regarding Kotlin + Android specifically (and would you tell it)?

It seems understandable if the integration is butter smooth with very little story at all.

Collapse
 
cjbrooks12 profile image
Casey Brooks

I've worked with Kotlin/Android a good bit, and would highly, highly recommend it. It is especially useful considering that Android has Java 8 support for syntax only, but standard libraries (like the Streaming API) are only available on much newer versions of Android and so cannot be used because of backward compatibility reasons. Kotlin lets you do all the functional .map { }, .filter { }, etc. that you want, and it still compiles down to Java 6 bytecode to work perfectly on all Android versions.

They also have the Anko, Kotlin Android Extensions, and Android KTX libraries, which are all a treasure trove of useful extensions to make the Android APIs much nicer to work with.

Collapse
 
defiance profile image
Defiance Black

Those links are all new to me; butter smooth Android integration indeed. Thank you, drive-by story-teller.

Collapse
 
smartym profile image
Sergey V. • Edited

I agree with you. What's important, JetBrains is constantly improving Kotlin and working on extending its capabilities. New versions are being often released, and that's great.

As a mobile app engineer, I'm happy about the appearance of such an advanced language as Kotlin. In our company, we use it more than 50% of our Android development.

Null-safety, extension-functions, coroutines, JVM backend, JavaScript official support, and many other cool features make it an effective tool for writing apps. By the way, TechBeacon included Kotlin in the list of 5 emerging languages with a bright future.

Thread Thread
 
defiance profile image
Defiance Black

Is it a fair assumption that the rest of the 50% is essentially HTML/CSS/JS? While I do webdev, the appdev side of things is still cloudy; I'm unsure if there'd be anything else required.

Your comment makes me better appreciate my PyCharm subscription. When the time comes, it's all a few clicks away.

Collapse
 
martinhaeusler profile image
Martin Häusler

Sorry, I've got no experiences with android so far. But considering that Kotlin is an officially supported language on Android, you shouldn't face too many issues. I'm using kotlin on the server side, and it works like a charm alongside our existing Java code.

Collapse
 
defiance profile image
Defiance Black

Heard that.

I'll come back to this top-down view of Kotlin to refresh my mind on its concepts. You should have seen my jaw when I read about inheritance (Python has spoiled me). It's also a great mini-syntax tutorial.

Thank you for writing this thing!

Collapse
 
vishnuharidas profile image
Vishnu Haridas

I strongly recommend Kotlin+Android. I am amazed with the better, functional style syntax, Extension Functions, Coroutines, Null-safety, and many other features. Threading and background processing is much easy with Coroutines.

Kotlinx - Kotlin Extensions is a collection of functions. For example, if you have a button in a layout XML named btnAccept, you don't need to do findViewById(R.id.btnAccept). Instead, you can directly use the name btnAccept inside your activity.

// example
btnAccept.setOnClickListener { callAcceptApi() }

Here's a nice list, #31DaysofKotlin, a full month of tips and tricks: twitter.com/i/moments/980488782406...

Collapse
 
bill1550 profile image
Bill Hart

I've been developing for Android now for the last 18 months exclusively with Kotlin. It is much more productive and safer than Java and is fully supported by Android. When working on older projects I find it is usually better to convert whatever classes I'm working to Kotlin. In particular the explicit and concise handling of nullable types is a major quality improvement.

Collapse
 
martinhaeusler profile image
Martin Häusler

I'm experiencing similar things on the server side. As I wrote in the article: null-safety alone should justify looking into Kotlin for every Java developer out there. It is a game-changer.