Kotlin 1.3-M2 Release is Android’s ‘Swift’ Moment

Kotlin is now at version 1.3-M2 – a slightly confusing moniker meant to celebrate a milestone towards the stable release of version 1.3.

One of its major new features is Contracts, an “experimental addition to the Kotlin type system.” Jetbrains, which manages Kotlin, says Contracts allow functions to better explain to the compiler what they’re doing, and are meant to be future-proof and withstand API changes.

There are also new standard library functions for unsigned types and collections; unsigned types and arrays of types should now feel like “first-class citizens.” Functions can now convert unsigned integers to and from strings in arbitrary cases, and extensions such as until and downTo support more range creation and progression of unsigned integers.

Those two examples front a long list of changes (JetBrains’s blog post on Kotlin 1.3-M2 is worth a read-through if you want all the gritty details) meant to prepare devs for the curve in the road ahead. Buried at the bottom of the blog post is a section on language changes, where we find the Kotlin compiler will no longer be reverse-compatible.

Jetbrains says the “old version” of kotlinc can be used for versions 1.0 and 1.1:

We’re deprecating the support for older source language versions through the -language-version flag with values 1.0 and 1.1 for kotlinc-1.3 and above. Note that this change only affects compilation of source code for old target versions; all binaries ever compiled with stable language versions will be supported by later versions of kotlinc. To compile your sources with Kotlin 1.0 and 1.1 you can use the corresponding old versions of kotlinc.

These are growing pains, and necessary ones. Contracts are billed as “experimental,” but they’re really beta. The feature handles a lot of error and exception-throwing instances, making it a bit less reliant on flags. It adds a bit of bulk to the code, but it’s a necessary parsing feature for Kotlin.

The lack of reverse compatibility is also fussy, but critical. In its way, these changes are reminiscent of another very popular upstart language: Swift. Early on, Swift was simple and breezy for developers; over time, the language assumed a lot of features some criticize as unnecessary bulk (the same crowd saying Apple should have just worked harder to make Objective-C more useful). It also had reverse compatibility issues with version 3.0.

Kotlin is Java’s heir apparent, much like Swift is for Objective-C, and at some point the student has to take steps to become the master. That time is now for Kotlin. Hate or love the changes, it’s all critical groundwork for a very solid future.

Related