Releases

Kotlin M1 Candidate

IntelliJ IDEA 11.1 has been recently released, and we are happy to announce a milestone candidate build for Kotlin IDE plugin, too. This post gives an overview of what happened over the last month.

Milestone Candidate Build is Ready for Your Evaluation

To install on IntelliJ IDEA 11.1 (Free Community Edition is available here), please follow the instructions from the Getting Started guide. In short:

You can always download nightly builds of Kotlin from our build server or build it yourself from sources.

Now we proceed to a short overview of the New and Noteworthy. Please refer to this blog post for the previously implemented features.

Little Things that Matter

First of all, we did very many bugfixes, improvements and other important things that are hard to demo. See the commit history on github and the closed issues in YouTrack.

Library

With the power of extension functions, Kotlin makes existing Java APIs better. In particular, we provide enhancements for JDK collections so that you can say things like this:

fun main(args : Array<String>) {
    val list = arrayList(1, 2, 3)
    val odds = list.filter {it % 2 == 1}
    println(odds.join(", "))
}

Here, filter() and join() are extension functions.

Implementation-wise, extension functions are just static utility functions, like “good old” Java’s Collecions.*, but with the “receiver.function()” call syntax, the IDE makes them much better: there is code completion that helps you browse through the API and learn it (just as if the extensions were normal class members):

You can navigate to sources of library functions:

And see the doc comments there:

The HTML version of the library docs is available here.

GitHub Support

Kotlin highlighting is now supported by github, including gist.

Annotations

Kotlin now supports annotations. Here’s a small example that relies on JUnit 4:

import org.junit.Test as test
import org.junit.Assert.*

class Tests {
    test fun simple() {
        assertEquals(42, getTheAnswer())
    }
}

Read more here.

String Templates

Now you can use multi-line string templates, for example:

println("""
  First name: $first
  Last name: $last
  Age: $age
""")

Simple Enums

Simple cases of enum classes are now supported. For example:

enum class Color {
  RED
  GREEN
  BLUE
}

Local Functions

Functions can be declared inside other functions:

fun count() : Int {
  fun count(parent : Entity) : Int {
    return 1 + parent.children.sum { count(it) }
  }
  return count(this.root)
}

Nullability

Kotlin now recognizes the @Nullable and @NotNull annotations). If the Java code says:

@NotNull String foo() {...}

Kotlin will trat foo() as returning a non-nullable String.

A short-hand operator (!!) for converting a nullable value into a non-nullable one is added:

val foo = getSomethingThatMayBeNull()
foo!!.bar() // throw NPE if foo is null, run bar() otherwise

Byte Code Unveiled

Click on the Kotlin button on the right edge of the IDEA window, and choose the “Bytecode” tab. You’ll see the byte-code Kotlin generates for your program!

Your feedback is very welcome. Have a nice Kotlin!

image description