Kotlin is a fairly new programming language built by 20 developers, give or take a few, at JetBrains. It was released in 2016 and was embraced by a lot of programmers. You might have heard of it very recently, with Google announcing Kotlin as their primary language for android development. So why do we need this new language? Let’s find out.
What happens when the builders of the best IDEs for Java are tired of the language? Well, they create a better version of it. That is how Kotlin was born. After years of experimenting, the brains at JetBrains have converted the powerful Java into a language that cuts 40% of the lines while retaining the semantics.
Kotlin basically is like an additional layer over Java. It is 100% interoperable with Java, but it does not translate code to Java and then to bytecode; rather compiles directly to bytecode and runs it on the JVM. It supports both Object Oriented and Functional Programming. We can also import Java classes into Kotlin directly. The latest versions on IntelliJ IDEs for Java provide an option to convert Java files to Kotlin files under the Edit menu.
Few of the most interesting features of Kotlin are its small and neat tweaks like
- Extension functions
- Methods and other blocks as expressions
- “When” expression
- Infix method notation
- Static NullPointerException check
- No need for semicolons
As you can see, Kotlin is not a language to take up without learning Java. Programmers will find it difficult to migrate to Kotlin immediately because of its dissimilar syntax. Despite the steep learning curve, it is well worth it. It is not a replacement for Java, Kotlin itself depends on Java and the JVM but a gradual migration is recommended. Though at its inception, Kotlin is expected to come up with many more interesting features in further iterations to come.
All in all, Kotlin looks like it would evolve to be the new Java. With Google’s support for Kotlin, there was a rise of 10 times in Stack Overflow questions that are tagged ‘Kotlin’ and with apps like Pinterest, Uber and hundreds of others being developed in Kotlin, it is only matter of time until it gets popular among developers.
So, should you use Kotlin for your next project? If it is a Java based project, then you definitely should! It’s a lot of fun!
You can learn more about Kotlin from the official site
Or start learning from the official documentation
You can also get started with learning and practicing Kotlin through their Kotlin Koans which is a GitHub repository that you need to clone.