▶ Developed with enterprise in mind ▶ A better Java ▶ It takes hint from Scala, C#, Groovy ▶ (some Groovy devs are involved) ▶ Strictly interoperable with Java Milestone 11 (M12 is coming)
for tedious tasks ▶ Type inference ▶ Nullable and non-nullable types ▶ Higher-order function literals ▶ First-class singleton object (à la Scala) ▶ Properties ▶ “Data” classes ▶ Operator overloading ▶ Focus on Enterprise Support
left: BinTree<T>, val right: BinTree<T>): BinTree<T> class Leaf<T>(val value: T) : Node(value) ... fun depth<T>(t: BinTree<T>): Int = when (t) { is Leaf -> 1 is Node -> max(path(t.left), path(t.right)) else -> throw UnsupportedOperationException() // no ADTs, must manage else case }
package com.example public final class ExamplePackage { public static String reverse(String self) { return StringBuilder(self).reverse().toString(); } }
x : Int) : Base { override fun print() { print(x) } } class Derived(b : Base) : Base by b fun main() { val b = BaseImpl(10) Derived(b).print() // prints 10 }
Map<String, Any?>) { val name: String by Delegates.mapVal(map) val age: Int by Delegates.mapVal(map) } val lazy: String by Delegates.lazy { println("computed!") "Hello" }
type system ▶ In Ceylon String? is a shorthand for String|Null Not a special case, defined within the language shared abstract class Null() of null extends Anything() {} shared object null extends Null() {} shared abstract class Anything() of Object | Null {}
over Java ▶ pretty true, you can basically mix them ▶ they will work almost seamlessly ▶ Most features are already in Java as “best practices” or idioms ▶ What Kotlin does is to raise them at the language level, with some sugar ▶ Developers listen to feedback a lot ▶ Compiles to Java 6 bytecode (works on Android)
identifiers shared variable value hello = "Hello"; class Dog satisfies Animal {} ▶ Interesting, elegant type system ▶ Strong metaprogramming ▶ Less interoperable ▶ (e.g., collections)
8 with a tad of Lombok @Data public class Person { private final String name, address; } @ExtensionMethod({java.util.Arrays.class, Extensions.class}) public class ExtensionMethodExample { public String test() { int[] intArray = {5, 3, 8, 2}; intArray.sort(); }} ▶ Doing away with backwards compatibility