Mar 8, 2019
Features of the official programming language of Android - Kotlin
The name comes from Kotlin Island, near St. Petersburg. It became the third language fully supported for Android, in addition to Java and C++.
Kotlin is a great fit for developing Android applications, bringing all of the advantages of a modern language to the Android platform without introducing any new restrictions. Recently, Google announced that it's adding Kotlin programming language's support in Android at I/O 2017. Since the release of Android Studio 3.0 in October 2017, Kotlin is included as an alternative to the standard Java compiler. Kotlin v1.3 was released on October 29, 2018, bringing coroutines for asynchronous programming. The latest version of Kotlin is 1.3.21.
Kotlin, which solves many pain points of Java, has been gaining momentum in recent past. Apart from being open source and featuring full Java interoperability, other best features of Kotlin make it something a programming enthusiast must know.
First and foremost, Kotlin in an open source programming language. This statically typed language was built by JetBrains. Apart from being an open source programming language, Kotlin doesn’t ask much when it comes to converting existing Java code, it happens with a single-click tool.
Kotlin compiles to JVM bytecode
Kotlin comes from industry
It solves problems faced by working programmers today. As an example, the type system helps you avoid null pointer exceptions. Research languages tend to just not have null at all, but this is of no use to people working with large codebases and APIs which do.
Full Java Interoperability
One of the best features of Kotlin programming language is its deep interoperability with Java, which is bound to attract more Java developers to learn Kotlin. It runs on the JVM and uses Java libraries and tools. It offers backward compatibility for Java versions 6 and 7.
Kotlin imposes no runtime overhead
The standard Kotlin library doesn’t have garbage, it’s tight and small. It has mostly focused extensions to the Java standard library. Many of its functions are inline-only that just become inline code. Kotlin has many optimizations which, specifically, help Android development.
IDE interop is entirely seamless
Kotlin allows you to keep using your productivity-enhancing tools. If you use IntelliJ, the code can be refactored, searched, navigated and auto-completed as if the Kotlin code was Java and vice-versa. There is full support for debugging, unit testing, profiling and so on.
Adopting Kotlin is low risk
It can be trialed in a small part of your code base by one or two enthusiastic team members without disrupting the rest of your project. Kotlin classes export a Java API that looks identical to that of regular Java code.
The defaulted parameters in Kotlin are pretty handy when you pass the arguments by name, instead of index. Their advantage is seen when there’s a function with tons of optional parameters.
Operators map to special method names so can override the behavior of the existing operators, but you cannot define entirely new ones. This strikes a balance between power and readability.
Thanks to the extension functions in Kotlin, you can add methods to classes without making changes to their source code. Similar to Scala implicit methods, you can add methods on a per-user basis to classes. While extension functions are often controversial, every now and then it’s very useful.
Markdown instead of HTML
This makes writing JavaDocs much more pleasant. The “Dokka” tool, which is the equivalent of JavaDoc, can read both Kotlin and Java source code and generate combined doc websites, both with its own style and also in the standard JavaDoc HTML style.
Kotlin wants you to write less code
Unlike Java, which needs you to write everything, Kotlin compiler can understand from the code and write the remaining code, for example, it can infer types in variable declarations. This increases productivity and saves time.
Kotlin is Safe
In Kotlin, there is less a chance of crashing the mobile applications as compared to Java. One of the most common drawbacks in many programming languages or Android coding language, including Java is that accessing a member of a null reference will result in a null reference exception. In Java, it would be the equivalent of a NullPointerException or NPE for short Kotlin’s type system is aimed to eradicate NullPointerException’s from code.
Kotlin stands out in a sea of new programming languages because of its focus on the ecosystem. If you search the web, you'll find tons of ways to solve Java's pain points by Kotlin and features of Kotlin aim to make Android development more fun. You can use it to write more expressive and effective code with fewer bugs.