Out
Out
Out
5978
ISSN No. 0976-5697
Volume 9, No. 3, May-June 2018
International Journal of Advanced Research in Computer Science
CASE STUDY
Available Online at www.ijarcs.info
Abstract: The purpose of this paper is to compare and conclude between Java and Kotlin in android application. We have taken different fields
and compared it with Java and Android. This paper attempts to study the various features of both Java and Kotlinand in the end concludes which
programming language fits the developers.
IV. KOTLIN Extension function can be elaborated with the example given
in [21].
Kotlin (Android_and_Kotlin) is a statically-typed
programming language that runs on the Java Virtual Machine As per the example, we need a function String class has to
and also can be compiled to JavaScript source code. It was was return a new string with first and last character removed; this
released to the public in February 2016. Its primary method is not available in the String class. The extension
development is from a team of JetBrains programmers based function declared outside class creates a functionality of the
in Saint Petersburg, Russia (the name comes from Kotlin specified class extending the predefined functionalities. The
Island, near St. Petersburg). In fact, the name Kotlin comes function can be extended as follows:
from Kotlin Island in Saint Petersburg[18].
fun String.removeFirstLastChar(): String =
In May, 2018, Google Android team announced that Kotlin is this.substring(1, this.length - 1)
now the official Language for Android development.
Developers have been using Kotlin to build Android apps in
previous years but Google just announced a first class support fun main(args: Array<String>) {
for it[18].
val myString= "Hello Everyone"
Both Kotlin and Java can be used to build Android apps. val result = myString.removeFirstLastChar()
Now the question is why should there be a switch in the
programming languages? println("First character is: $result")
}
V. LITERATURE
In a comparative study: Prof. Panchaland, R. K and Patel, “Kotlin provides the ability to extend a class with new
A.K have studied many works in android with java, so they functionality without having to inherit from the class or use
have studied with Kotlin instead of java. This work can be any type of design pattern such as Decorator. This is done via
further enriched to achieve Kotlin related mobile apps. [18] special declarations called extensions. Kotlin
On 26th June, 2017, Android Authority published a video on supports extension functions and extension properties.”[4]
10 Reasons to try Kotlin for Android development It shows
what new features Kotlin brings to android application This Extension function is not present in java. For availing the
development [19]. Adding Extensions, Handling Null functionality of extension functions, Android frameworks are
pointers are some of the benefits discussed in the paper. commonly used.
Holla, S. and Katti M.M. has discussed security issues of But Android framework sometimes makes things difficult.
Android application and future scope in their paper [20]. The Java provides only one solution, that is to create wrappers.. [5]
issues like android store’s risk of getting virus affected But Kotlin has given us the advantage of extension function
application. They have discussed the future scopes like which would eliminate the difficulties posed by Android
addition of more sensors to the future devices which will framework.
make Android more secured.
If it is required to add some extra features in a class, in most Kotlin does not have checked exception. All exception classes
programming languages, a new class is derived. An extension in Kotlin are descendants of the class Throwable. Every
function is a member function of a class that is defined outside exception has a message, stack trace and an optional cause. [6]
the class.
Using throw expression can be used in Kotlin to handle
exceptions [22]:
this.name = name;
fun fail(message: String): Nothing this.roll = roll;
{ throw IllegalArgumentException(message) } this.marks = marks;
this.elective = elective;
val s = person.name ?: throw IllegalArgumentExcepti }
on("Name required")
}
It is a topic of debate whether a checked exception is better than non
checked exception. Some programs find way to implement checked This secondary constructor feature is absent in Java. The
exceptions in Kotlin, but here we state the advantages of not using a utility of secondary constructor is that it reduces the lines of
checked exception. code.
Thinking from developers’ point of view, Kotlin would be Number of lines of codes in Kotlin is much less than the
preferred due to the following reasons [10]: number of lines of code in JAVA for achieving the same
output. An example of this is taken from [24] is given below:
1. Language and environment are mature
[10] “What are the advantages of Kotlin over Java? “, viewed on [18] R.K. Panchal, and, A.K. Patel, 2017, A comparative study:
8th May, 2018, from “https://www.quora.com/in/What-are- Java Vs kotlin Programming in Android , in International
the-advantages-of-Kotlin-over-Java Journal of Innovative Trends in Engineering & Research,
[11] P. Sommerhoff, January, 2018, “Kotlin vs. Java: 9 Benefits September 2017, vol 2 Issue 9, pp 4 – 10.
of Kotlin for Your Business”, viewed on 7th May, 2018 from [19] Android Authority, 2017, “10 reasons to try Kotlin for
https://business.udemy.com/blog/kotlin-vs-java-9-benefits- Android development”, viewed on 9th May, 2018 from
of-kotlin-for-your-business/ https://www.youtube.com/watch?v=LEi1ecigDFE
[12] G. Suite, n.d., “Android”, viewed on 9th May, 2018 from [20] S. Holla and M.M. Katti, 2012, ANDROID BASED
https://www.engineersgarage.com/articles/what-is-android- MOBILE APPLICATION DEVELOPMENT and its
introduction SECURITY, in International Journal of Computer Trends
[13] I. Majocha, December, 2017, “Report: Top Android Security and Technology, 2012, Vol 3, Issue 3, pp 486- 490
Problems in 2017”, viewed on 9th May, 2018 from [21] Programiz, n.d., “Kotlin Extension Function”, viewed on 9th
https://dzone.com/articles/report-top-android-security- May, 2018 from https://www.programiz.com/kotlin-
problems-in-2017 programming/extension-functions
[14] Developers, n.d., “About the platform”, viewed on 9th May, [22] “Kotlin”, viewed on 8th May, 2018 from
2018 from https://developer.android.com/about/ https://kotlinlang.org/docs/reference/exceptions.html
[15] Fossbytes, n.d., “Most Popular Android Versions In [23] E. Petrenko, n.d., “Catching exceptions with less code in
February 2018 (Always Updated List)”, viewed on 9th May, Kotlin”, viewed on 9th May, 2018 from
2018 from https://fossbytes.com/most-popular-android- http://jonnyzzz.com/blog/2017/02/15/catchall/
versions-always-updated/ [24] Hype.codes, 2017, “ Kotlin Vs Java”, viewed on 9th May,
[16] Turbofuture, April, 2016, “Android Version Names: Every 2018 from https://hype.codes/kotlin-vs-java
OS from Cupcake to Marshmallow”, viewed on 9th May, [25] Schildt, The Complete Reference Java, Seventh Edition,
2018 from https://turbofuture.com/cell-phones/Cupcake- Chapter 1, page 9
Donut-Eclair-Froyo-Gingerbread-Honeycomb-Android-OS-
Version-Codenames-and-Why [26] https://code.tutsplus.com/tutorials/learn-java-for-android-
development-introduction-to-java--mobile-2604, viewed on
[17] “Why does Android use Java?”, viewed on 9th May, 2018 9th May, 2018
from https://stackoverflow.com/questions/3560963/why-
does-android-use-java