Today we’re releasing Kotlin 1.2. This is a major new release and a big step on our road towards enabling the use of Kotlin across all components of a modern application.
Kotlin 1.2 is already bundled in IntelliJ IDEA 2017.3, which is being released this week. If you’re using Android Studio or an older version of IntelliJ IDEA, you can install the new version from the Tools | Kotlin | Configure Kotlin Plugin Updates dialog.
This release includes a lot of work done by external contributors, and we’d like to thank everyone who sent us feedback, reported issues, and especially those who submitted pull requests.
A multiplatform project allows you to build multiple tiers of your application – backend, frontend and Android app – from the same codebase. Such a project contains both common modules, which contain platform-independent code, as well as platform-specific modules, which contain code for a specific platform (JVM or JS) and can use platform-specific libraries. To call platform-specific code from a common module, you can specify expected declarations – declarations for which all platform-specific modules need to provide actual implementations.
For more information on the feature, please check out the documentation.
As mentioned previously, we’re also working on a set of common libraries to allow you to move more of the logic to common code:
- kotlin.test, included out of the box in Kotlin 1.2, lets you write your test once and run it under both the JVM and JS;
- kotlinx.html supports isomorphic rendering – using the same code to render HTML in the backend and in the frontend;
- kotlinx.serialization allows you to easily marshal Kotlin objects between different tiers of your application, using JSON or ProtoBuf as serialization formats.
Note that multiplatform projects are currently an experimental feature; it means that the feature is ready for use, but we may need to change the design in the subsequent release (and if we do, we’ll provide migration tools for existing code).
Over the course of development of 1.2, we’ve put a lot of effort in making the compilation process faster. We’ve already reached approximately 25% improvement over Kotlin 1.1, and we see significant potential for further improvements, which will be released in 1.2.x updates.
The graph below shows the difference in compilation times for two large JetBrains projects built with Kotlin:
Other Language and Library Improvements
We’ve also made a number of smaller improvements to the language and the standard library:
- A more concise syntax for passing multiple arguments to an annotation (array literals);
- Support for the
lateinitmodifier on top-level properties and local variables, as well as checking whether a
lateinitvariable is initialized;
- Smarter smart casts and improved type inference in certain cases;
- Compatibility of the standard library with the split package restrictions introduced in Java 9;
kotlin.mathpackage in the standard library;
- New standard library functions for working with sequences and collections, including a set of functions for breaking a collection or sequence into potentially overlapping groups of a fixed size.
For more information and code examples, please see the What’s New in Kotlin 1.2 documentation page.
Kotlin Around the World
Since the release of Kotlin 1.1 in March of this year, Kotlin has made huge gains in adoption all around the world. The culmination of that was KotlinConf, our first worldwide conference, with around 1200 attendees gathering in San Francisco on November 2-3rd. We’ve recorded all the talks, and the videos are now available.
Kotlin is now an officially supported language for Android development, with out-of-the-box support in Android Studio 3.0, as well as official samples and style guides published by Google. As a result, Kotlin is already used in more than 17% of projects in Android Studio 3.0, including many apps from the hottest startups as well as Fortune 500 companies.
On the server side, Spring Framework 5.0 has been released with many Kotlin support features, and vert.x has been supporting Kotlin since their 3.4.0 release. Also, Gradle now comes with support for Kotlin DSL out of the box, and the Gradle Kotlin DSL project is rapidly approaching the 1.0 release.
The number of lines of open-source Kotlin code on GitHub has now exceeded 25 million. And on Stack Overflow, Kotlin is both one of the fastest-growing and one of the least-disliked languages.
The community growing around Kotlin is also really amazing. There are over 100 user groups all around the world, and so many talks that we have a hard time keeping track of all of them – but for those that we do know about, the talks map gives you a very good idea of how wide-spread the use of Kotlin really is.
And for those who’re just starting to learn Kotlin, there’s an ever-growing number of books (including our own “Kotlin in Action”, now available in English, Russian, Japanese, Chinese and Portuguese), online courses, tutorials and other resources.
Meet the Team: Webinar and Reddit AMA
To share with you more information on the new release, we plan to host a webinar on multiplatform projects with Kotlin 1.2 on December 7th, 18:00 CET. Please register; space is limited!
The Kotlin team will also conduct an AMA (Ask Me Anything) on the Kotlin Reddit on December 5th. We’ll start at noon CET, and we’ll be there with you for the next 24 hours.
How to Upgrade
As always, you can try Kotlin online at try.kotlinlang.org.
- In Maven, Gradle and npm: Use
1.2.0as the version number for the compiler and the standard library. See the docs here.
- In IntelliJ IDEA: 2017.3 has Kotlin 1.2 bundled, in earlier versions Install or update the Kotlin plugin to version 1.2.
- In Android Studio: Install or update the plugin through Plugin Manager.
- In Eclipse: install the plugin using Marketplace.
- The command-line compiler can be downloaded from the Github release page.
Compatibility. In Kotlin 1.2 the language and the standard library are backwards compatible (modulo bugs): if something compiled and ran in 1.0 or 1.1, it will keep working in 1.2. To aid big teams that update gradually, we provide a compiler switch that disables new features. Here is a document covering possible pitfalls.
Have a nice Kotlin!