Exit Full View

Kotlin

Kotlin is a language similar to Java, and runs on Java's JVM.

I started learning it, just to try something new, but I was soon hooked.

Java requires lots of boiler plate code, and while Java 7 and 8 has brought many much needed improvements, it is showing it age. I can only see a downhill trend for Java, unless Oracle takes a drastic new path (and I can't see that happening, but I hope I'm wrong).

The most obvious improvement Kotlin makes is its Null Pointer avoidance. Switch to Kotlin, and you won't be plagued by the dreaded NullPointerException.

Kotlin's smart casting, is really nice too, and it will be horrible to go back to Java's convoluted syntax.

However, an even more damming problem with java is the 'equals' operator. We need two, one to test for equality (Object.equals), and another to test for 'sameness' (Java's '=='). Kotlin uses '==' for equality and '===' for 'sameness'. Much nicer to read. Java's Object.equals is broken, because it is a method call, if the object if null, you get a null pointer exception. So in every project, I create (or reuse) my own static 'equals' method, and never use Object.equals directly.

A more subtle difference is the 'val' versus 'var' (or final versus non-final in Java parlance). Kotlin subtly nudges me to choose 'val' rather than 'var', and I'm sure my code is more robust because of it.

Cons of Kotlin

I'm using Eclipse, and the tools for Kotlin aren't as mature yet. For example, Refactoring isn't quite as good. I can't see any on-the-fly javadoc viewer (or Kotlin's equivalent of Javadoc). There is no highlighting of 'TODO' comments within .kt files.

Over time, these will improve, and I'm sure that InteliJ IDEA is better suited to Kotlin development than Eclipse (IDEA is written by the same people as Kotlin). However, I'm always sceptical of being forced by convenience to use a single proprietary IDE.

A sea of red. A small syntax error can cause large swathes of code to be highlighted as errors.

Compile times are longer.

The Kotlin's Eclipse plugin is a little buggy - I see errors quite frequently.

Compatibility from Kotlin back to Java. I haven't tried calling Kotlin code from Java yet, but I'm sure there will be a few issues. There will probably be similar issues calling Kotlin code from other JVM languages such as Groovy (something I plan to do very shortly, as ParaTask needs a scripting language).