days
-6
-5
hours
-2
-1
minutes
-4
-9
seconds
-3
0
search

Kotlin 1.2.70 significantly improves incremental compilation for Kotlin/JS

Gabriela Motroc
Kotlin
© Shutterstock / Legend_art

Kotlin 1.2.70, the newest bugfix and tooling update for Kotlin 1.2 brings a lot of goodies, including standalone Kotlin compiler native binaries and a bunch of IntelliJ IDEA support improvements. Let’s take a look at what’s in this update.

Kotlin 1.2.70 arrives with exciting changes in tow, including incremental compilation improvements for Kotlin/JS, native binaries built with Excelsior JET for the standalone Kotlin compiler, as well as new refactorings, inspections, and intentions to the IntelliJ IDEA plugin.

As usual, you’ll find the complete list of changes in the changelog.

Kotlin 1.2.70 highlights

Incremental compilation improvements for Kotlin/JS

We talked about Kotlin/JS in a previous article but it gets even better as the team has greatly improved incremental compilation for Kotlin/JS, according to the blog post announcing Kotlin 1.2.70. What does that mean exactly? It depends on the project structure, of course, but it can speed up development builds up to seven times, perhaps even more.

Furthermore, Kotlin/JS Gradle builds now support cross-module incremental compilation. You should, however, keep in mind that since it is still experimental, it is disabled by default. Here’s how you can enable it:

  • In a Gradle project, add kotlin.incremental.js=true into gradle.properties or local.properties
  • In a project built with IntelliJ IDEA, go to Settings | Build, Execution, Deployment | CompilerKotlin Compiler | Kotlin to JavaScript and check Enable incremental compilation (experimental).

Multiplatform projects update

kotlin-stdlib-common received a bunch of platform-specific annotations that are marked with the @OptionalExpectation annotation [introduced in the previous update]. In short, “the compiler will ignore these annotations on common declarations during compilation of platform modules that have no corresponding actual annotation class,” as JetBrains’ Sergey Igushkin explained in the blog post.

You can use some JVM-specific annotations such as @JvmName in the common code of a multiplatform project and compile it to JavaScript.

SEE ALSO: Contracts are coming to Kotlin 1.3

IntelliJ IDEA support improvements

This update brings a new inspection with a quick fix for converting a non-lazy collection transformations chain into a sequence equivalent. The main benefits of this improvement are that it

  • helps avoid unnecessary temporary allocations overhead
  • may significantly improve performance of complex processing pipelines

The list of improvements also includes:

  • Intentions to replace an if null-check with ?.let and the other way around
  • Inspection to detect unnecessary with calls
  • Intention to convert a property getter to initializer
  • Inspection and quickfix to replace assertTrue(a == b) with assertEquals(a, b)
  • “Redundant return label” inspection
  • Quick-fix for default parameter value removal
  • forEach parameter unused” inspection
  • Lots of bug fixes and performance improvements

Standalone Kotlin compiler native binaries

The JVM version of the standalone Kotlin compiler has company! The Github releases now contain a native, system-dependent version for every major platform (Linux, macOS, and Windows). The binaries are built with the Excelsior JET AOT compiler; if you wish to build small files or scripts, you should know that these binaries have faster startup times.

The Excelsior JET runtime supports some JVM and specific options that you may pass with -Jusing the kotlinc wrapper script. You’ll find all recognized options in the Excelsior JET documentation.

Check out Sergey Igushkin’s blog post for the complete list of highlights.

Author
Gabriela Motroc
Gabriela Motroc is editor of JAXenter.com and JAX Magazine. Before working at Software & Support Media Group, she studied International Communication Management at the Hague University of Applied Sciences.