Kotlin Update is the Reforming Factor for Mobile App Development Industry

17 July 2017

The first milestone of Android’s first class language is out. The early access program has begin for Kotlin 1.2 and the release of 1.2 – M1 has created excitement among mobile app developers. This will allow the features of new language by default which were available previously in the 1.1x which was under the experimental 1.2 language version setting. This new API can be previewed in the standard library.
The list not so big changes can be seen in the changelog.
Language Characteristics: array literals in annotations
The single notable language characteristic which is proposed in this milestone is nothing but array literals and its usages are compelled to annotation arguments.
Earlier, in order to specify the array of values, the developer has to write in the following format –

@CacheConfig(cacheNames = arrayOf(“books”, “default”))
    // ….
}

But in this newly released version of Kotlin 1.2, a literal can be utilized instead of the arrayOf function:

@CacheConfig(cacheNames = [“books”, “default”])

public class BookRepositoryImpl {
    // ….
}

A proposal is given by an IDE inspection to do the use of new syntax which has a collection of literals.
Inline function that has alternatively optional parameters

Till now, it wasn’t possible to announce the higher order function which has an optional function parameter like the one given here:
   inline fun <E> List<E>.printItems(transform: (E) -> String = { it.toString() })

The mobile app developer had to develop functions that were non-inline or mark the operational parameters as noinline. Both the cases couldn’t justify the aim of operational parameter inlining.
But with this release, the following cases are now fully supported.

Standard Library API
This released feature comes with two KEEPs
1. Kotlin Evolution
2. Enhancement Proposals

Both were with respect to the standard library API.

The first one, KEEP-49 introduces extra functions and convertible extensions for BigDecimal and BigInteger types.
The second, KEEP-11 covers many operations that are related to the division of collections and sequences:
1. chunked(size: Int) – This extension function divides a collection into the blocks of provided size;
2. windowed(size: Int, step: Int) – This takes a window of the provided size and tours it along the collection.
3. pairwise() extension gives back all the subsequent pairs in a collection.
Also, there are few other enhancements like fill() and shuffle() extensions for lists like MutableList and shuffled().

JavaScript
In the previous version, when 1.1.2 got released opt-in JS typed arrays support were introduced. Post enabling, it translated the Kotlin primitive arrays like DoubleArray, IntArray etc. into JavaScript typed arrays. But with this new release, opt-in is not needed any longer since this support is allowed by default.
This new update can be tried from two ways, via Maven/Gradle or IntelliJ IDEA.
The release of new features in Kotlin language are gaining popularity like fire in the forest and many mobile development Companies are using this language. Although the release of this language happened nearly a month from the time this blog was written, it has started to become popular among Android app developers. Moreover, this language has turned out to be the growth factor for the mobile app development industry.

For more technology updates, visit India App Stores. Also, sign up as an android developer to receive assured cashback.

Leave a Reply



Latest Post


Social Post