Kotlin 1.2 Released With Cross Platform Support |
Written by Mike James |
Thursday, 30 November 2017 |
JetBrains has just announced the release of Kotlin 1.2 and it is already supported in Android Studio 3. What's new and what's missing? Kotlin has become an important language since Google adopted it as the alternative to Java in Android Studio. It really makes Android programming easier by reducing the need for long chunks of boilerplate code that the average programmer just doesn't get, or perhaps more accurately doesn't bother understanding at a deep level. There is an old saying in physics that you don't ever really get to understand anything, you simply get used to it. So it is with many aspects of a writing Java. You may have understood it once, but these days you simply let the IDE generate it for you. Kotlin 1.2 has a new feature which in the past might have elicited a bit of a yawn. Another Java compatible language extends its reach into areas not many are going to take advantage of. The big difference is that with Kotlin as the language of Android it suddenly is worth considering it in other environments if only because your skills transfer. The new feature is multi-platform projects. At the moment Kotlin supports the JVM, JavaScript and Native code as its three targets. In this new version you can create projects that can run on the JVM or JavaScript. There are common modules which work on either platform and then platform modules which are specific to the target.
This doesn't sound that amazing, but the clever part it that the common modules can bind to the platform dependent modules by "expected and actual declarations". This allows the same backend logic to access the same data via different UIs. For example, if the common module has:
then it can make use of the function hello but it will be supplied by one of the platform modules, e.g on the JVM:
It isn't a perfect solution, but it is direct and easy to understand and JetBrains is working on common libraries that can be used in common modules. A good improvement is a 25% speedup of the compiler: JetBrains promises more speedups in decimal point updates. Language changes are thin on the ground and mostly this is a good thing - a stable language is important - but the announcement lists:
Of course, all of this should be backward compatible. Some enhancements that were not listed in the announcement but are worth knowing about are:
Sadly coroutines are still experimental even though they were introduced in 1.1. When this feature, complete with async and await, make it into the final build it will make a great difference - to Android programs in particular. The announcement also provides a look at how well Kotlin is doing: The steep increased occurred when Google announced Kotlin as an Android language.
More InformationKotlin 1.2 Released: Sharing Code between Platforms Related ArticlesThe Programmers Guide To Kotlin - Type Kotlin Begins Its Takeover Of Android New Kotlin Style Guides Unveiled Kotlin - New Language For Android To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.
Comments
or email your comment to: comments@i-programmer.info <ASIN:1871962536> |
Last Updated ( Thursday, 29 August 2019 ) |