7 things I like about Kotlin
The syntax of Java is dated, version 1 was released in the last millennium. For at least 10 years I wonder what the designated successor will be. A promising candidate was Scala. Powerful concepts but its syntax is sometimes difficult to read. Another candidate was JavaScript: easy to learn, functional in its core but no: despite being so successful in the industry JavaScript has some serious design flaws that cannot be fixed. And then there is Go, but I don’t like the pointer arithmetic symbols. This is for C programmers. Other languages such as Groovy and Ceylon didn’t convince either.
Today I know there is no single successor for Java. Instead there will be many. And the power of Java lies within its virtual machine, the JVM. (Even though a JVM is too heavy for Docker containers compared to Go binaries.)
What about Kotlin? When I heard first about Kotlin from James Strachan in 2012 I was pretty much sceptical. Groovy did not suit my taste. We’re in 2016 now and a lot happened. The language has matured and is now ready to take over the leadership as an industrial purpose programming language. Here’s why:
1Kotlin has a concise syntax
It is not as verbose as Java and not as dense as Scala or Groovy. The mixture is just right. And yes — getters and setters are gone! Finally.
2 Interop with Java
You can mix and match Kotlin with Java code. Calls from Java to Kotlin work as well as calls from Kotlin to Java. There is some impedance mismatch but it is tolerable.
3 Kotlin native
Kotlin runs on the JVM and on JavaScript engines. But there are plans by JetBrains to provide a native version as well. I’m really looking forward to trying it out.
4Spring support
Due to Java interop it’s already possible to write Kotlin code using frameworks like Spring. At start.spring.io you can even generate a Spring Boot app with Kotlin files! And support for Kotlin will be extended in the upcoming Spring Framework 5.
5Convert Java files to Kotlin files
IntelliJ IDEA does all the hard work for you. Simply choose this conversion option and you’re done. Not really, but it’s a great start and it helps you understand the language.
6 Awesome video courses
Reading textbooks about programming languages is deprecated. Instead, check out the video courses from Hadi Hariri published by O’Reilly.
7 The fun keyword
Functions are important. So why not choose an appropriate keyword for it? function is too long and fn is too short. Using fun is a lot more fun!
So give it a try! Have fun :)