At the end of Google I/O 2017, Google presented a brand-new programming language for Android applications: Kotlin. Should we expect a revolution in Android development?
What is Kotlin?
A new Android language full of new features: it is now Android’s secondary programming language. Note that, contrary to certain rumours, Kotlin does not replace Java; it is announced as a complement to it. This programming language was not developed by Google, but by JetBrains: a Russian programming company based in Saint Petersburg, which is none other than the creator of the WebStorm IDE.
What does Kotlin bring?
Kotlin includes most of the features found in Java. However, there are more than 15 exclusive features:
- Lambda expressions & inline functions
- Primary constructors
- Operator overloading
- Extension functions
- First-class delegation
- Companion objects
- Null safety
- Type inference for variable and property types
- Data classes
- Smart casts
- Singletons
- Separate interfaces for read-only and mutable collections
- String templates
- Declaration-site variance & type projections
- Coroutines
- Properties
- Range expressions
A renewal that was proving necessary
The Java code imposed by Google was limiting developers’ work far too much: this language forced developers to be more technical in their work, rather than thinking about its UX/UI. Using Kotlin is a “liberation” for developers who are waiting for the release of Java 8, an update full of promise that is slow in coming. However, not all developers are ready to opt for Kotlin: given that this language is not made official by Google, it can be risky to use Kotlin for your code base.
A few code examples
Displaying “Hello World”:
When:
You can also find other code examples on Kotlin’s official website.