BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News The Roadmap to Kotlin 1.1

The Roadmap to Kotlin 1.1

This item in japanese

Lire ce contenu en français

Kotlin development is heading towards version 1.1; Kotlin lead language designer Andrey Breslav explained the roadmap to JetBrains’ JVM language new version, which will include major new language features.

Kotlin 1.1 will provides a number of new language features:

  • type aliases are meant to be an abbreviation mechanisms for longer types declarations, such as function signatures; type aliases will not introduce new types and can be used interchangeably with the original definition.

  • bound method references will be extended to support taking a reference to a member of an object. In this way, you can take a reference to the equals method of a String object and assign it to a predicate to use it later: val p: Predicate<String> = “foo”::equals. Kotlin 1.0.x already supports this for types.

  • delegated properties will be allowed at the top level, in a class, or in a function:

    fun foo() {
      val lazyBar by lazy { ... }
      while (...) {
        if (...) {
          lazyBar.doBaz()
          ...
        }
      }
    }
    

    Delegated properties are a mechanism to implement once and for all certain kinds of properties, such as lazy, observable, and map-stored properties, so they do not need be implemented each time.

  • data classes will support inheritance, thus making it possible to derive a data class from another. Data classes are classes that just hold data, and for which Kotlin automatically generates accessors, equals, hashCode, and other common methods. This will also make it possible to extend a data class from within a sealed class:

    sealed class C() {
      data class Example(...) : C()
    }
    
  • destructuring will allow to assign composed names to arguments of lambdas, such as in the following example, where the argument to forEach, a pair, is destructured in its two components:

    myMap.forEach {
      (k, v) ->
        println(“$k => $v”)
    }
    
  • coroutines will provide the backbone for Kotlin async behaviour. According to Breslav, coroutines are more general than the async/await model introduced in C# 5. Kotlin will also provide async/await, but built on top of coroutines, not as primitives:

    fun loadImage(url: URL) = async {
      val bytes = await(loadBytes(url))
      bytesToImage(bytes)
    }
    

On the tooling front, Kotlin 1.1 will include direct support for Java 8/9 features, such as default method generation. Additionally, the JavaScript backend will be brought in line with the actual set of language features.

Kotlin development is driven by the Kotlin Evolution and Enhancement Process (KEEP), based on a GitHub repository where all planned use cases are described.

Kotlin 1.1 will be both source and binary compatible with previous versions, meaning that new versions of Kotlin compiler will not break compatibility with older source code and binaries.

Rate this Article

Adoption
Style

BT