Upcoming Change: More Null-safety for Java

Our battle for combining null-safety and Java interop has been a long one already:

  • we started off treating all Java reference types as nullable, and it was too inconvenient;
  • then we employed external annotations to specify nullability, created KAnnotator, but the whole thing was too fragile when versioning was concerned, and sometimes the users couldn’t do what they needed to (especially when it came to inheritance);
  • in M9 we discarded the annotations (for the time being), and introduced platform types, now anything could be done, but we lost (some) type-safety;
  • in M11 we started bringing the useful aspects of annotations back by issuing warnings where Java nullability constraints were violated.

Now, we are planning to make one more step and use annotations in combination with platform types to bring back as much type-safety as possible. Continue reading

Posted in Language design | Leave a comment

Upcoming Change: Function Types Reform

Kotlin M12 will likely bring another change that is crucial for implementing a useful reflection library for Kotlin. In short, we are going to unify FunctionX and ExtensionFunctionX to be represented in the same way at runtime, but it will not affect our ability to create type-safe builders and other DSL-like constructs. Continue reading

Posted in Language design | 11 Comments

Announcing Anko for Android

We’re excited to announce a library we’ve been working on for Android development, which, among other things allows the creation of Application Interfaces in a type-safe and dynamic way using a DSL.

A Sample Taste

Here is a small example describing some of Anko’s possibilities. Imagine we need to create a simple sign-up form consisting of an EditText for a username and a “Sign up” Button. The code for this, using Anko would be:

Continue reading

Posted in Android | 52 Comments

More changes: Enum Syntax, Another Deprecation and More

Enum Syntax

Currently the syntax for enums with non-trivial constructors is kind of monstrous:

Continue reading

Posted in Language design | 59 Comments

More Deprecations Coming

There are two more items on the language cleanup list: backing-field syntax and static type assertion operator. Continue reading

Posted in Language design | 19 Comments

Upcoming Change: Syntax For Annotations

Kotlin’s syntax for annotations was inspired by C#, which surrounds them with square brackets:

But brackets are precious for a language designer, and we would really like to use them later for something else, so we are considering changing the annotation syntax to the more Java-like @-based one:

NOTE: the short syntax that does not require [...] nor @ is going to be kept anyways, so you will still be able to say this:

This change has some implications, though. Continue reading

Posted in Language design | 29 Comments

Upcoming Feature Deprecations

As we are finalizing the language design, many things have to be cleaned up, and among these are features that were initially designed and (often partly) implemented, but turned out not to be worth the trouble supporting them.

In the upcoming M12 milestone, we are going to deprecate such features, so that you could migrate your code before they are removed completely. Continue reading

Posted in Language design | 18 Comments

Eclipse Plugin Alpha is Out!

Kotlin support in IntelliJ IDEA has always been among our top priorities, but we have been working on Eclipse support as well, and today we are happy to present the first alpha result of this effort.

Although it’s only a start and many things will be improved over time, it already features

  • Building and Running Your Code
  • Java Interoperability
  • Code Highlighting
  • Debugging
  • Navigation
  • Basic Code Completion (Ctrl+Space)
  • Auto-Import
  • Unit Testing

Installation

To give it a try you will need a clean installation of Eclipse Luna. The Kotlin plugin is available from the Eclipse Marketplace. The easiest way to install the Kotlin plugin is to drag-and-drop this button into a running Eclipse window:

Drag to your running Eclipse workspace to install Kotlin Plugin for Eclipse
Continue reading

Posted in Tools | 9 Comments

Kotlin M11 is Out!

Today we are releasing a new milestone: Kotlin M11, which brings such long-awaited features as secondary constructors, a first glimpse of true reflection support for Kotlin and much more. Continue reading

Posted in Releases | 80 Comments

Follow-up: New Class Object Syntax

In the previous post I explained the rethought design of what used to be called “class objects”: they are now more uniform with normal nested objects, have names (name may be omitted, but a default one will be used by the compiler), and we can write extensions to them.

One of the goals of that post was to gather feedback on the term we proposed, namely “default object”, and many of you rightfully stated in the comments that the term has a disadvantage: it is easily misread for “a default instance of the class”. Now we are looking for a better term and need some more feedback…

Update: thanks to everyone, with your help, we chose companion. Continue reading

Posted in Language design | 53 Comments