Kotlin 1.2 EAP now available

Good news for all Kotlin coders - early access program of Kotlin 1.2 available
19 July 2017   1447
Kotlin

Statically-typed programming language that runs on the Java Virtual Machine and also can be compiled to JavaScript source code.

Kotlin team recently announced the start of the early access program for Kotlin 1.2. First milestone 1.2M1 was out recently. This is reported by official Kotlin Blog

Let's have a good look at the most interesting features of EAP.

Language feature: array literals in annotations

The single notable language feature proposed in this milestone is array literals, whose usages are constrained to annotation arguments.

In order to specify an array of values, coder had to write something like this:

@CacheConfig(cacheNames = arrayOf("books", "default"))
public class BookRepositoryImpl {
    // ....
}

Now, in Kotlin 1.2 a literal can be used instead of the arrayOf function:

@CacheConfig(cacheNames = ["books", "default"])

public class BookRepositoryImpl {

    // ....

}

Additionally, an IDE inspection will propose you to use the new syntax of collection literals where appropriate.

Inline function with optional functional parameters

Earlier, it was impossible to declare an inline higher order function with an optional functional parameter like the following:

inline fun <E> List<E>.printItems(transform: (E) -> String = { it.toString() })

One had to either make the function itself non-inline or mark the functional parameter as noinline. In either case that defeated the purpose of functional parameter inlining.

Now this case is fully supported.

Standard Library API

This release features two KEEPs (Kotlin Evolution and Enhancement Proposals) regarding the standard library API.

The first is KEEP-49 . It provides additional operations and conversion extensions for BigIntegerand BigDecimal types.

The second one is KEEP-11 which covers a number of functions related to partitioning collections and sequences:

  • chunked(size: Int) extension function partitions a collection into blocks of the given size;
  • windowed(size: Int, step: Int) takes a window of the given size and moves it along the collection with the given step returning the sublists of elements falling into each window;
  • pairwise() extension returns all subsequent pairs in a collection.

JavaScript

Earlier in 1.1.2 release developers have introduced the opt-in JS typed arrays support. When enabled it translates Kotlin primitive arrays, such as IntArrayDoubleArray etc, into JavaScript typed arrays. Now the opt-in is no longer required as this support is enabled by default.

You can find more info at changelog and Kotlin Blog.

JetBrains to Roll Out Ktor Framework

Framework is suitable for writing back-end projects and microservices in the Kotlin language
20 November 2018   437

JetBrains developers told about the release of the stable version of the Ktor 1.0 framework. It helps to create asynchronous servers and clients in related systems. According to the creators, the framework is suitable for writing back-end projects and microservices in the Kotlin language. Documentation and project generator are published on the official website.

First of all, it is worth noting that this is an open source project that is distributed under the Apache 2 license. The main components are:

  • HTTP server running on a virtual machine. It works on Netty, Jetty, and server-side Java programs. It can be placed in a container, embedded in desktop or Android applications, as well as run on Tomcat. Moreover, it corresponds to the paradigm of the application of twelve factors.
  • Multiplatform HTTP client. Although asynchronous, it uses the same coroutines and I / O elements that control the server.

Tools will help the developer to customize the main components of the application.

The Kotlin / Native project supports Ktor, starting with version 0.8. In this case, the working version of Kotlin / Native 0.9 was released in early September 2018. In it, developers added support for unsigned types and interoperability with C, Objective-C / Swift.