Kotlin provides you some amazing and powerful features over Java. That’s why developers love Kotlin. There are many tech giants who use Kotlin before Google announces the official support for it.
Following are seven main features of Kotlin:
- Concise code
- Null safety
- Expressive code
- Modern features
- Interoperability with Java
- Native conversion (Kotlin Native)
Developers always love clean and concise code. Less code takes less time to write, less time to read, and also makes easy to maintain it.
Kotlin has really concise code compare to java. It drastically reduces the amount of boilerplate code. So compare to java you will write less amount of code in Kotlin, which increases the speed of your development.
Rough estimates indicate that Kotlin requires 40% less line of codes compare to java.
More than 70% android app crashes due to null pointer exception of java. Java does not provide any ways of protection against the null. The developer has to handle it on his/her own.
But Kotlin handles nulls really nicely. In Kotlin you cannot get null pointer exception implicitly. Kotlin compiler by default doesn’t allow any types to have a value of null at compile time. So if you use Kotlin then it will reduce your app crashes and gives better user experience to your user.
Expressive code means the code that can be easily understandable by every programmer.
Kotlin is really expressive. All data types, built-in functions, keywords, etc. are really very expressive and easily understandable. Kotlin is designed in such a way so that even a person who never codes in kotlin can easily understand its code.
As kotlin is a fourth generation language, it introduces and combined a lot of new features like Lambda functions, smart casts, null safety, operator overloading, etc. Which will help you in increasing your productivity? Kotlin is influenced by six major languages and it inherits a lot of best features of them.
Kotlin is 100% interoperable with java. You can easily call Kotlin code from Java and Java code from Kotlin. This makes adoption much easier and lower-risk. There’s also an automated Java-to-Kotlin converter built into the IDE that simplifies migration of existing code. This makes easy to work on an existing Android project. You can keep your old java file as it is and create new features in the new kotlin file.
According to official documentation, the current implementation targets ECMAScript 5.1 but there are plans to eventually target ECMAScript 2015 as well.
The Kotlin compiler tries to comply with the following goals:
- Provide output that is optimal in size
- Provide interoperability with existing module systems
Kotlin Native is a technology for compiling Kotlin code to native binaries, which can run without a virtual machine. That way your kotlin code will directly run on a system without any additional runtime or virtual machine.
Note that kotlin native is still in beta (as of 12-July-2019)
Kotlin Native supports the following platforms:
- iOS (arm32, arm64, emulator x86_64)
- MacOS (x86_64)
- Android (arm32, arm64)
- Windows (mingw x86_64)
- Linux (x86_64, arm32, MIPS, MIPS little endian)
- WebAssembly (wasm32)
So guys above are major features of kotlin. Let me know in the comments if I miss your favorite one.
Please check every day for new posts on Kotlin and other programming topics. Till then Keep Coding, Keep Loving.