In the recent Google I/O ‘17 conference, Kotlin was made the official language for Android development, along with Java. Like most people, it was the first time i had heard about the language.This prodded me do a little digging on this mysterious new language. In this blog post, I am sharing some of my findings. What is Kotlin? Kotlin is a statically-typed programming language that runs on the Java virtual machine and also can be compiled to JavaScript source code or uses the LLVM compiler infrastructure. Its primary development is from a team of JetBrains programmers based in Saint Petersburg, Russia. While the syntax is not compatible with Java, Kotlin is designed to inter-operate with Java code and is reliant on Java code from the existing Java Class Library, such as the collections framework. The name comes from Kotlin Island, near St. Petersburg. Andrey Breslav mentioned that the team decided to name it after an island just like Java was named after the Indonesian island of Java. Is Kotlin an object-oriented language or a functional one? Kotlin has both object-oriented and functional constructs. You can use it in both OO and FP styles, or mix elements of the two. With first-class support for features such as higher-order functions, function types and lambdas, Kotlin is a great choice if you’re doing or exploring functional programming. What advantages does Kotlin give me over the Java programming language? Kotlin is more concise. Rough estimates indicate approximately a 40% cut in the number of lines of code. It’s also more type-safe, e.g. support for non-nullable types makes applications less prone to Null Pointer Exceptions (Huge Relief!!). Other features including smart casting, higher-order functions, extension functions and lambdas with receivers provide the ability to write expressive code as well as facilitating creation of DSL. Can I use Kotlin for Android development? Yes. Kotlin is supported as a first-class language on Android. There are hundreds of applications already using Kotlin for Android, such as Basecamp, Pinterest and more. How do I get started with Android Development using Kotlin? Before being officially adopted by Google, Kotlin support was an add-on package on Android Studio, just like native support. Android studio 3.0 (with Kotlin support) is still in its beta phase, so it’s recommended that you run it alongside a stable version. I found an online tutorial here. For the purists who’d love a guide book, there’s one called “Kotlin Development for Android” by Antonio Leiva. The book is available in physical and digital forms,though you might have to pay. You can also have a look at the official Kotlin documentation here. So that’s it for now folks, I hope you find it useful. Pranav Udupa |
Blog > Miscellaneous >