Kotlin 1.2 M2 is out

We’re happy to announce the second milestone release for Kotlin 1.2. The primary focus of this release is concerned with stability and bugfixes in Kotlin compiler and tooling as well as improvements of Kotlin standard library. It also includes many of the tooling features available in the upcoming release of Kotlin 1.1.4.

We appreciate your feedback regarding the new features or any problems that you may run into with this release.

The complete changelog since 1.2 M1 can be found here with some major changes listed below.

Compiler

Breaking change: Java-default method calls

Up to now Kotlin interface members overriding Java-default methods while targeting JVM 1.6 produced a warning on super calls: Super calls to Java default methods are deprecated in JVM target 1.6. Recompile with '-jvm-target 1.8'. In 1.2-M2 release we’ve replaced the warning with error, thus requiring any such code to be compiled with -jvm-target 1.8 option

Standard library

Revised windowed/pairwise operations

We have been listening to your feedback about chunked/windowed/pairwise functions KEEP-11, which were released to preview in the previous milestone 1.2-M1, and based on it we decided to make some changes to these functions:

  • windowed function now has its step parameter defaulting to 1.
    It also gets an additional optional parameter partialWindows, which controls what to do with incomplete windows in the end. By default it is false, which means incomplete windows are dropped.
  • pairwise function name was too confusing, it was unclear how it paired the elements together. Now it is called zipWithNext, so it is more clear that each element is zipped with the next element in a collection.

Common math operations in the standard library

There was a longstanding request to support math operations in the standard library KT-4900. Until now one had to resort to math functions and constants from java.lang.Math class in JVM platform and to kotlin.js.Math which exposed native JS Math functions to Kotlin code in JS platform.
But now we’re introducing the following groups of API in the kotlin.math package:

  • constants: PI and E;
  • trigonometric: cos, sin, tan and inverse of them: acos, asin, atan, atan2;
  • hyperbolic: cosh, sinh, tanh;
  • exponentation: pow (an extension function), sqrt, hypot, exp, expm1;
  • logarithms: log, log2, log10, ln, ln1p;
  • rounding:
    • ceil, floor, truncate, round (half to even) functions;
    • roundToInt, roundToLong (half to integer) extension functions;
  • sign and absolute value:
    • abs and sign functions;
    • absoluteValue and sign extension properties;
    • withSign extension function;
  • max and min of two values;
  • binary representation:
    • ulp extension property;
    • nextUp, nextDown, nextTowards extension functions;
    • toBits, toRawBits, Double.fromBits (these are in the kotlin package).

The same set of functions (but without constants) is also available for Float arguments.
Most of these functions (except the binary representation group) are also available in JS, thus solving the problem of writing the same calculations for both platforms.

Pre-release notes

As with other milestone releases, we give no backwards compatibility guarantees for new language and library features. Anything introduced in milestone releases of 1.2 is subject to change before the final 1.2 release. When we reach final RC, all binaries produced by pre-release versions will be outlawed by the compiler: you’ll be required to recompile everything that was compiled by 1.2‑Mx.
However all the code compiled by 1.1.x and earlier releases is perfectly fine without recompilation.

How to Try It

In Maven/Gradle: Add http://dl.bintray.com/kotlin/kotlin-eap-1.2 as a repository for the build script and your projects; use 1.2-M2 as the version number for the compiler plugin and the standard library.

In IntelliJ IDEA: Go to Tools → Kotlin → Configure Kotlin Plugin Updates, then select “Early Access Preview 1.2” in the Update channel drop-down list, then press Check for updates.

The command-line compiler can be downloaded from the Github release page.

On try.kotlinlang.org: Use the drop-down list at the bottom-right corner to change the compiler version to 1.2‑M2 (coming soon).

This entry was posted in Releases and tagged , . Bookmark the permalink.

11 Responses to Kotlin 1.2 M2 is out

  1. elect says:

    Just trying the awesome math package.. toDegrees and toRadians are missing…

  2. alanfo says:

    Great news that the commoner math functions are to be integrated into the standard library which I’m sure will be appreciated by just about everybody! I have a few points though:

    Is there any point exposing min() and max() functions when we already have the more versatile minOf and maxOf functions in the standard library?
    A notable omission for me is the cube root function, cbrt(), which is in Java, JS and C/C++ and is used fairly often. It can admittedly be reproduced with the more long winded: d.pow(1.0 / 3.0) but not as nice as cbrt(d).
    I’d consider making the pow() extension function infix. We’d then be able to do the more natural: 3.0 pow 4.0 rather than just 3.0.pow(4.0).
    Agree with ‘elect’ that toDegrees() and toRadians() should be there.

  3. soywiz says:

    Is there any reason to not expose Float/Double raw bit functions to kotlin.js? You can use typed arrays with a common buffer to implement them easily

  4. Pingback: Интересные материалы для Android-разработчика #83 - Подкасты Android Dev

  5. Lukáš Kúšik says:

    Please add a sumByLong method on iterables.

  6. Stéphane Lavergne says:

    Will the first stable 1.2 release include coroutines ready for production? I couldn’t find any clear roadmap on the matter and this will seal the deal for our projects (vs both Golang and ECMAScript 7).

  7. Nick K says:

    I’m curious if improvements to Kotlin Scripting (.kts files) is on the roadmap. Specifically around things like external dependency resolution or inclusion of other script files. I would love to use Kotlin to replace my system groovy scripts.

  8. Kotlin is definitely an exciting development and we have to see what the future brings in terms of adaption. Our Android guys recently spent a few weeks digging into the topic.

Leave a Reply

Your email address will not be published. Required fields are marked *