Wrapping Up

Creating Android apps using Kotlin has many benefits. The language is supported as a first-class citizen by Google for programming Android devices. By using Kotlin for Android development, you can access all the benefits of Kotlin when programming on the Android platform—the code is concise and expressive, it’s less error prone, it boosts productivity, and the list goes on. In addition, the Android Studio IDE provides features to convert Java code and code snippets to Kotlin syntax for easy porting.

In this chapter we created a small app to illustrate the power of Kotlin for programming Android apps. The application fetches data from the web and displays airport status information in a RecyclerView. Throughout the code, we can see the Kotlin idioms and capabilities shine. Since fetching data from a remote service can take some time, to speed up access we used coroutines to make parallel calls to the service. Whereas parallel execution can improve performance, we can’t update the UI from arbitrary threads. This is because UI components are not thread safe and can be updated only from the main thread. Again, using the coroutines’s capabilities we direct the update of the UI components to happen in the main thread, concurrent with the user interactions.

The app we created nicely illustrates the different capabilities of Kotlin and also shows the ease with which we’re able to use coroutines to create apps that can provide good performance and, at the same time, be responsive to user interactions.

Throughout the course, we’ve seen the capabilities of Kotlin as a highly expressive, concise, safe, and powerful statically typed language. We’ve seen the various capabilities of the language, from the ability to program object-oriented code to writing both imperative and functional-style code. We’ve seen the facilities to create internal DSLs, thanks to Kotlin fluency, and the ease with which we can create both parallel and concurrent code with coroutines. With all this power packed into the language, Kotlin has emerged as one of the few multi-platform languages where the code can be targeted to different runtime environments. I hope this course has stimulated your creativity and given you some good ideas of how you can apply this wonderful language to your projects. Thank you for reading.


Get hands-on with 1200+ tech skills courses.