Title: How Simpler and Shorter Code of Kotlin Has Changed the Android Development Experience?
1How Simpler and Shorter Code of Kotlin Has
Changed the Android Development Experience?
2Intro
- 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(No Transcript)
4Kotlin Advantages
- 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 Javas
equivalent code - Easy debugging due to more human-readability ease
- Playful yet much faster Android app development
process
5- 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.
6- 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.
7How about IntelliJ IDEA, Eclipse or Netbeans?
- Android Studio is built on IntelliJ IDEA, an IDE
built by JetBrainsthe 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. Kotlins target to be available on
multiple platforms and support for other IDEs
will continue as before.
8- 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
9Kotlin Vs 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 lineFor
instance, in Java, if we want to create a typical
data class, well need to write (or at least
generate) this code
10 11How much code is this on Kotlin? Just this
simple data class
12- 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.
13We can do things like this
14Safe Calls with Kotlin
- Extension functions
- We can add new functions to any class. Its 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
15Extension functions
- We can add new functions to any class. Its 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
16We 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
17- 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
18Fetching the list of data to mobile device
from server
19Displaying that data to User Interface
20For data rendering using Recycler Adapter
21(No Transcript)
22- Original Source
- http//www.azilen.com/blog/kotlin-framework-for-an
droid-development/
23Thanks You www.azilen.com Let us know if you
have any Question! info_at_azilen.com
1-972-325-2243