Kotlin M2 is Out!

Some news websites told you that Kotlin M2 was out earlier this week. Well, now we make it come true 🙂

In the M2 Candidate post I told you about JavaScript and Android support, as well as new Language Features. Now it’s time for more updates, examples and plans.

Proceed to Kotlin M2 Installation Instructions.

A Little More on The Language

The previous post gave an overview of the new Language Features. Here’s a little more:

First, I’d like to remind you that in M1 we added the “assert not null” operator: !!, it replaces the sure() function we used to have in the standard library. Now, we removed sure() from the library, so some of you code might break, but it’s very easy to fix.

People keep asking whether Kotlin has literals for lists or maps. The answer is: strictly speaking, no, but we have function in the library that are good enough for that:

val list = arrayList(1, 2, 3)
val map = hashMap(
    "John" to "Doe",
    "Jane" to "Smith"

Note that to() is also a function.

Also note that now you can use any type that has a function named invoke() in a callee position:

fun foo(x : Method) {

You could only use function types in this role before, now you can turn any object into a “function” by providing an invoke() extension or member.

I have to apologize for not all of that being present in the docs yet. A little piece of good news is that we are working on making our docs open source as well as the rest of the project. Now you can find the sources (in Confluence wiki format) in our github repo, and thus contribute your corrections/additions in the for of pull-requests.

A little more news on the docs: our KDoc tool is maturing rapidly, thanks to James Strachan. Now it supports search and links to github sources of the libraries.


As I mentioned above, the big things in this milestone were JavaScript support in the IDE and Android. It’s always good to start with examples, so here’s a set of projects you can open in your IDE and play with. Please, find some instructions in the previous post.

Examples for JavaScript:

Examples for Android:

have fun playing with these examples, and contribute more!

IntelliJ IDEA Plugin

The IntelliJ IDEA plugin is progressing pretty fast. Most of the work is done behind the scenes (performance, tighter integration with the Java IDE), but there’re a few user-facing things to point out, too:

  • The IDE now displays error messages formatted in nice HTML-like way, which makes the messages more readable.
  • Enjoy the “Specify explicit type” refactoring when you need to add a type to your declaration.
  • Cross-language Find Usages and Rename between Kotlin and Java code is now supported.
  • Navigation to inheritors is supported. This also works across languages: inside Kotlin, for Kotlin classes extending Java classes, and vice versa.
  • Also, we changed the IDE icons, and they are very nice now. More work coming on this topic.

Our priority for the next milestone is IDE performance and improvements to null-safety support for Java classes.

To install the M2 plugin: If you had you M1 installed, it will update automatically from the plugin repository. It checks for updates once a day, so if you don’t want to wait, initiate the check manually:

You will be prompted to update your Kotlin library, since the annotation format has changed a little. If you miss the “Update Kotlin Runtime” balloon, open the message in the Event Log:

Note that you have to uninstall the M2 Candidate and any nightly builds of the Kotlin plugin or builds installed manually before installing M2 from the main plugin repository.

Build Tools: Ant and Maven

Our build tools integration, including Maven, has improved a little bit fewer repositories, easier set-up process. You may need to update your pom’s. See instructions here.


A little more on what we plan to do next. As mentioned above, the IDE priorities are performance and Java-integration wrt null-safety. The language work will bring the following improvements:

  • Kotlin will provide means of defining properties that turn into Java’s static final constants.
  • We will support the concept of data classes, that are somewhat similar to Scala’s case classes.
  • Kotlin will support a dynamic type, which is needed mostly to accommodate the JavaScript APIs that don’t fit with the statically typed approach.
  • We’ll also improve the type inference algorithm tremendously. We owe you this for a long time by now…

Library-wise the plans are as follows:

  • Port most of the Kotlin’s standard library to the JS platform.
  • Make Kotlin’s collections variant, but preserve the seamless interop with java.util.* collections. This actually deserves a separate post.
  • Provide good library support for Android. We suspect that most of Android’s XML files can be replaced with Kotlin’s builders that are much nicer in many ways…

Have a nice Kotlin!

And don’t forget to give us feedback. Thanks.

Comments below can no longer be edited.

12 Responses to Kotlin M2 is Out!

  1. Avatar

    jerry says:

    June 11, 2012

    This totally unrelated but Kotlin is small village in central-west Poland where I come from. That was funny to see “Kotlin” on HN, anyway: Kotlin in polish is a concatenation of two words “kot” and “lin”, which stands for “cat” and “tench”, renaming of your project to a CaTench would be funny 🙂
    I’m not really here because of your project but i promise, I’ll check it later in spare time.


  2. Avatar

    Otto Christian says:

    June 15, 2012

    I’m glad to hear that good library support for Android is planned, and especially that builders will be available to use for layout and other things instead of XML files. Does that mean no more I always hate that because it often causes weird problems when something get out of sync!

    I wanted to mention the JS examples (Creatures, KotlinPuzzle) don’t work out-of-the-box. Actually I will post the problem in the forum so as not to crowd these blog comments with too many specific details.

  3. Avatar

    Guangyu says:

    June 17, 2012

    Kotlin library will grow fastly. Since the library is so important for a language, I hope the core library is simple and concise enough, and the extension library is modular .

  4. Avatar

    kkndone says:

    June 17, 2012

    i still strongly hope kotlin can provide builtin map and list literal, they’have important position when considering programming language as enjoyable

    • Avatar

      Andrey Breslav says:

      June 18, 2012

      What’s the difference between a built-in literal and what Kotlin has?

      • Avatar

        Jan Kotek says:

        June 22, 2012

        I guess some constructs for making List and Maps creation easyier. Something like:

        val list = List("aa","bb","cc")
        val map = Map("key1"->"value1", "key2" -> "value2") //scala

        • Avatar

          Andrey Breslav says:

          June 22, 2012

          How’s this easier than what’s mentioned in the post? It’s even the same number of characters (apart from the function names, that can be made shorter)

          • Avatar

            MuppetGate says:

            July 5, 2012

            Looks much the same to me.

            Perhaps the ‘to’ method can be overloaded with ‘->’

          • Avatar

            Andrey Breslav says:

            July 5, 2012

            No: “->” is used for function literals

      • Avatar

        Russell Zornes says:

        September 12, 2012

        val list = [1, 2, 3]
        val map = [“John” : “Doe”, “Jane” : “Smith”]

        There are few alternatives that are more simple than that.

  5. Avatar

    Guangyu says:

    August 30, 2012

    What about the difference between the next version and the version 0.2? Do you have any news about the next version? When will you distribute it?

    • Avatar

      Andrey Breslav says:

      August 30, 2012

      M3 will be out in early September