will have to use Java ▶ Enterprise loves it ▶ Limited expressivity is a bless for maintenance ▶ It is extremely backwards compatible ▶ Lots of 1.4 code is still in the wild
«the redundant type serves as valuable documentation […] the redundancy allows the programmer to declare the intended type, and thereby benefit from a cross check performed by the compiler 1» — Gilad Bracha 1http:/ /bugs.java.com/bugdatabase/view_bug.do?bug_id=4459053
say #fuckit boolean java.util.List#add(E e) ▶ Appends the specified element to the end of this list ▶ Throws UnsupportedOperationException if the add operation is not supported
new Person("John Doe", "some street"); String name = john.getName(); john.setAddress("some other street"); A feature we find in modern programming languages String name = person.name; person.address = "some address";
the methods def name: String def address: String def address_=(address: String): String ... val john = Person("John Doe", "some street") val name = john.name john.address = "some other street"
public string Address { get; set; } public Person(string name, string address) { ... } } ... var john = new Person("John Doe", "some street"); string name = john.Name; john.Address = "some other street";
Public Property Get Name() As String Name = m_Name End Property Public Property Let Name(ByVal s As String) m_Name = s End Property ... Dim name As String = person.Name person.Address = "some other street"
typed, «feels dynamic» (Bruce Eckel) ▶ Scala has a vibrant community and it’s 10 year old ▶ It’s gaining traction in the industry (sort of) ▶ so, what’s wrong with Scala?
convince me that it is simple, but if you have to deal with code like this2 def map[B, That](f: A ⇒ B)(implicit bf: CanBuildFrom[Repr, B, That]): That …then you are actively scaring people away ▶ Try and invoke this from Java. It’s impossible ▶ SI-43893 Resolution: NOT A BUG 2“The longest suicide note in history” http:/ /stackoverflow.com/q/1722726 3https:/ /issues.scala-lang.org/browse/SI-4389
▶ Developed with enterprise in mind ▶ A better Java ▶ It takes hint from Scala, C#, Groovy ▶ (some Groovy devs are involved) ▶ Statically typed Milestone 9 out (v0.9 — Oct, 15th)
(in Algol) ▶ The null reference ▶ There is nothing wrong with a bottom value ▶ The problem is null handling Equivalent to annotating your Java 85 code with @NotNull and @Nullable @NotNull Map<@NotNull String, @NotNull Person> myMap = new HashMap<>(); 5also possible with JetBrains’ own annotations from Java 6 onward
(in Algol) ▶ The null reference ▶ There is nothing wrong with a bottom value ▶ The problem is null handling Equivalent to annotating your Java 85 code with @NotNull and @Nullable @NotNull Map<@NotNull String, @NotNull Person> myMap = new HashMap<>(); 5also possible with JetBrains’ own annotations from Java 6 onward
compiler error val s2: String? = null // compiles // nullable result val anUnsafeResult = someStringFunction() val c: Char? = anUnsafeResult?.charAt(0) // non-nullable result val aSafeResult = anotherStringFunction() val c2: Char = aSafeResult.charAt(0) // nullable result with default val c3: Char = anUnsafeResult ?: 'x' // default value
address: String) equals() and toString() are auto-generated val myFoo = Foo("John Doe", "was here") // no `new` here val theName = myFoo.name myFoo.address = "was there" ▶ getName(), getAddress() and setAddressString() are auto-generated for Java compatibility.
state cannot be initialized val name: String // function bodies are allowed fun eat(Food food): String { return "nom nom" } } I hear you saying “that’s already in Java 8”. This is Java 6 compatible, though.
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 other known types }
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 }
{ title {+"XML encoding with Kotlin"} } body { h1 {+"XML encoding with Kotlin"} p {+"this format can be used as an alternative markup to XML"} a(href = "http://jetbrains.com/kotlin") {+"Kotlin"} p { for (arg in args) +arg } } }
King (Hybernate, Seam) ▶ Another strongly, statically-typed programming language ▶ Interesting type system ▶ …brought to you in a somewhat weird syntax ▶ v1.1 out (Oct, 9th 2014)
//`value` auto infers type shared Integer currentValue { return count; } shared void increment() { count++; } } If you are wondering why shared you are not alone
operator (plus(X)), ▶ Comparable<X> supports the comparison operators (compare(X)), ▶ Correspondence supports the index operator, ▶ Ranged supports the segment and span operators
Ceylon produces modules natively ▶ .car files (basically .jar + extra metadata) ▶ Actually, Kotlin has an identical concept, but it is not yet released
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
Interesting type system ▶ Elegant design ▶ Strange, arbitrary syntactic choices ▶ Interoperability Java → Ceylon is fine, ▶ Ceylon → Java: I had some problems