1 / 23

How Simpler and Shorter Code of Kotlin Has Changed the Android Development Experience?

This blog is about exploring Kotlin strengths for making android development easy, quick and playful. It describes several Kotlin advantages along with specimen codes that we have created for our Hello World News Application with specific objective.<br>

AzilenTech
Télécharger la présentation

How Simpler and Shorter Code of Kotlin Has Changed the Android Development Experience?

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. How Simpler and Shorter Code of Kotlin Has Changed the Android Development Experience?

  2. Intro At Google I/O 2017, the Android team had announced remarkable support for Kotlin, the statically typed programming language for the JVM (Java Virtual Machine). In fact, Kotlin has already become a buzz in the Android development for years, and the number of projects developed using Kotlin is consistently increasing at Github as well. However, this language was always in a very awkward position for Android developers because it had never been supported officially. But now, the status quo has changed.

  3. KotlinAdvantages: Easy Learning Curve Advantage • A concise statically-typed programming language that is extremely easy to read and write • The modern and Android-compatible language that is especially designed to be type-and null-safe • Much simpler and shorter code than Java’s equivalent code • Easy debugging due to more human-readability ease • Playful yet much faster Android app development process

  4. Open Source Advantage • Kotlin has always been an Open Source project under Apache 2 and there is a strong possibility to move Kotlin into a non-profit foundation. • Kotlin encourages a strong and company independent open developer ecosystem while growing the Android platform.

  5. 100% Java Compatibility Advantage • The level of interoperability between Java and Kotlin can be considered as one of the most powerful advantage • The possibilities of perfect compilation of Java and Kotlin code co-existing in the same project • You can use the majority of Java libraries and frameworks in Kotlin projects including advanced frameworks • You can use Kotlin without taking any drastic steps like converting an entire project to Kotlin.

  6. How about IntelliJ IDEA, Eclipse or Netbeans? • Android Studio is built on IntelliJ IDEA, an IDE built by JetBrains—the same company behind the Kotlin language. The JetBrains team has ensured Kotlin works great with IntelliJ IDEA. • Starting with Android Studio 3.0, tooling support for Kotlin is bundled directly into Android Studio. Kotlin’s target to be available on multiple platforms and support for other IDEs will continue as before.

  7. What Happens to Existing Languages? Thought Kotlin has been declared official Android language, existing languages have also been empowered in the best possible way.  For example: • Android O supports Java 8 libraries • C++ is intended to furnish better native experience and enhanced with expanding performance profiling tools and APK debugging tools

  8. KotlinVs Java Main feature Advantage Full Java Interoperability • Kotlin is 100% interoperable with Java so you can utilize all existing Android libraries including annotation processing, so data binding and Dagger work in a Kotlin application. • Hence, the java friendly Android developer can easily learn Kotlin and making it compatible with Android projects. Data Classes In the Java world, a typical data class has tons of boilerplate code that one needs to skip while finding out the real use of that class, such as the getters and setters. But in Kotlin, we can easily create a POJO (Plain Old Java Object) with getters, setters, equals(), hashCode(), toString() and copy() in a single line:For instance, in Java, if we want to create a typical data class, we´ll need to write (or at least generate) this code:

  9. How much code is this on Kotlin? Just this simple data class:

  10. Null safety When we develop the application using Java, most of our code is defensive. We need to keep checking continuously if something is null before we use it. Otherwise we may find unexpected NullPointerException. Kotlin, as many other languages, is null safe because we need to explicitly specify if an object can be null by using the safe call operator.

  11. We can do things like this:

  12. Safe Calls with Kotlin Extension functions • We can add new functions to any class. It´s a much more readable substitute to the typical utility classes we all have in our projects. We could, for instance, add a new method to fragments to show a toast:

  13. Extension functions We can add new functions to any class. It´s a much more readable substitute to the typical utility classes we all have in our projects. We could, for instance, add a new method to fragments to show a toast:

  14. We can do things like this with Kotlin: Functional support (Lambdas) What if instead of having to write the creation of a new listener every time we need to declare what a click should do, we could just define what we want to do? We can indeed. This (and many more interesting things) is what we get thanks to lambda usage:

  15. As a part of our exploration about how Kotlin actually works with the real world application, below are the Kotlin specimen codes we have created for our Hello World News application. The objective is to fetch data from server to mobile device and getting it displayed to UI in the desired format using Kotlin. The specimen codes are described in three different stages: • Code for fetching the list of data to mobile device from server • Code for displaying that data to User Interface • Code for data rendering using Recycler Adapter

  16. Fetching the list of data to mobiledevice from server

  17. Displaying that data to User Interface

  18. For data rendering using Recycler Adapter

  19. Original Source : http://www.azilen.com/blog/kotlin-framework-for-android-development/

  20. Thanks You www.azilen.com Let us know if you have any Question! info@azilen.com | +1-972-325-2243

More Related