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:

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:

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.

Examples

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.

Plans

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.

About Andrey Breslav

Andrey is the lead language designer working on Project Kotlin at JetBrains. He also works on making the Java language better, serving as a Java Community Process expert in a group for JSR-335 ("Project Lambda"), and occasionally speak at software conferences such as Devoxx or JavaOne.
This entry was posted in General and tagged . Bookmark the permalink.

12 Responses to Kotlin M2 is Out!

  1. jerry says:

    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.

    Cheers!

  2. Otto Christian says:

    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 R.java? 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. Guangyu says:

    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. kkndone says:

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

  5. Guangyu says:

    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?

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">