www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Kotlin language

Kotlin is a new statically typed language for the Java VM. It's similar to
Scala, but it's simpler. It looks easy to learn.

-----------------------

It seems to have well designed null-safety, types annotated with ? are nullable:
http://confluence.jetbrains.net/display/Kotlin/Null-safety

All statically typed languages that are coming out in the last years seem to
have something similar.

It even has the little amount of type state to make things handy and safe:

var a : String = "abc" // not nullable string
var b : String? = "abc" // nullable string
val l = b.length() // error: variable 'b' can be null
val l = if (b != null) b.length() else -1 // OK

Plus some other nice details. But I have not programmed wiht Kotlin and I don't
know know it manages the situations of partially initialized objects in a
contructor (that is an important special case).

-----------------------

It has type-safe Groovy-style "builders", to define tree-shaped data structures
in a a semi-declarative way. They are useful to generate XML, lay out UI
components, describe 3D scenes, etc:
http://confluence.jetbrains.net/display/Kotlin/Type-safe+Groovy-style+builders

-----------------------

It has ranges:
http://confluence.jetbrains.net/display/Kotlin/Ranges

// Check range membership, i.e. contains
// (optimized for Ints)
if (a in 1..100) {
    print("in range")
}

// Iterate through a range, i.e. iterator()
// (optimized for Ints)
for (x in 1..100) {
    print(x)
}

Bye,
bearophile
Jul 19 2011