Kotlin is a modern programming language built by JetBrains, the company who developed tools like Intellij and also JetBrains IDE on which Android Studio is based on.Kotlin is a wonderful language. It’s concise,extensible,expressive,and very powerful language. Kotlin has a much cleaner syntax, and a joy to read and write. Not only this it has some superb safety features in terms of nullability and immutability, which make android apps more healthy and performant by default.
Some Developers maybe will not happy with Kotlin announcement, for them i have an special information that kotlin’s compiler emits java byte code. Maybe you are thinking what is special about this, yeah it’s special it means kotlin can call java and java can call kotlin.This means in a single project, you can use kotlin and java freely or if you want, you can mix the two languages.
Story behind Kotlin, Why google Announced new programming language
Going back in the year 2010, two tech giants Oracle and Google arguing that google violated its copyright by using Oracle’s Java technology in android. Google has won against Oracle in 2012. The jury decided that Google’s use of the disputed code was “fair use.”
This two tech giants have been battling over years in separate courts over whether Google have to pay $9 billion of dollars for using 11,500 lines of java codes in Android or not.
I think this is the main reason, why google switching to kotlin.
Although open-sourced Kotlin was first announced in July 2011, after that JetBrains maintain it towards forward by adding some stable features and relaunched it in 2016. Like Swift Google won’t own kotlin.The language will continue developed and maintained by JetBrains.
Cool features of Kotlin
I chooses some key features of kotlin every android developed should know. Kotlin is modern mature language and growing day by day.Many maybe think im a kotlin lover, But no im not “I am a Android Developer who saw kotlin awesome features which can give you better experience and reliability while developing apps”. I sum up some features of kotlin which are as,
We already talked about this feature, that kotlin and java are fully interoperable, which means in a code half of it can be on java and rest of it can be on kotlin, and it will work as once together.
Android Studio 3.0 preview also giving a tool that can convert java code into kotlin .So if have method in java but does not know how to write it in kotlin, it can be very helpful for beginners.
When working on development of an app you ever fall in the condition on which you want to use some java library methods but those are not supportable by your app minimum API .Your answer maybe yes, personally i made came up with that type of situations. This is the Problem when you are using java but with Kotlin, all standard library features are available no matter what your apps minimum API. Yes,that means you can use Streams API on apps with API lower than 24.
Katlin is a modern language as any other modern language it has safe Nullability System, Lambdas and Method References for better performance through out the code, this also improves apps performance by default as it provides better memory management and clean connection between codes.
I heard many of my known Android Developers arguing over once thing, like many they also think kotlin does not have a community like java. Yeah maybe they are quite right about it, java is very popular language for a long time, java connects lots of people worldwide and also there are large amount of tutorials are on the internet. But if it’s the reason you are thinking about, there is nothing worry about Kotlin tutorials.
JetBrain’s Kotlin developing team takes every proposal, needs and ideas from the community and keeps them in mind while developing the language.There is also a kotlin slack team, I’m sure that you will like it.
Kotlin is still developing and in future Katlin maybe be able to run in different platforms like iOs,web sites and also at game engine development without the support of JVM.
#6. Operator overloading
Oh..! yes finally, we can use operator overloading at Kotlin. Kotlin allow us to redefine operators to our types. To implement operator overloading kotlin provide a member function or an extension funtion with a fixed name, for the corresponding type.
We think those are awesome features which will make Developers work easy and they can give more time to app ideas.
Comparison to Java
Kotlin have many features which java doesn’t have and also it solves many issues with java. We are not describing each of those issues, just giving you a idea.
What Kotlin has over Java
- Lambda expressions and inline functions
- String templates
- Primary Constructors
- Operator Overloading
- Data classes
- Companion Objects
and many more..
What Java has that Kotlin does not
There are also features java has but kotlin can’t have to become a modern programming language which are,
Java issues fixed in Kotlin
- Null reference are controlled by the type system
- No raw types
- Arrays in Kotlin are invariant
- Kotlin has proper function types, as opposite to Java’s SAM-conversions
- use site variance without wildcards
- Kotlin does not have checked exceptions
If you are interested to know more about what this you can download kotlin reference from here.
So, is it really java days are over for Android Development, my answer is no. But Google will cut Java from Android slowly it’s for sure. Beginners who want to learn android app development , for them i have an message “Don’t listen to anyone go for Kotlin”. It’s a very easy language to learn and i personally felt that java and katlin is quite similar, if you can code with katlin you can also code with java. But i’m suggesting you katlin as, it’s a new language so everyone beginner now you can easily tie up with them (although experience will other developers to learn faster then beginner). And the other thing Kotlin is more advance than java in terms of performance.
This is what i think about kotlin, what about you tell me in comments?
If you have any questions or suggestions tell me at comments and if you like the article, don’t forget to subscribe my blog.
I'm obsessed with python and write articles about python tutorials for Django, Data Science, and Automation.