Kotlin 1.4 Online Event

Share This Post

Recently, the Kotlin Online Event organized by Jetbrains was held to discuss the latest version of the language and also to replace what in principle and under normal circumstances would have been the KotlinConf that has been postponed for next year.

The event took place over 4 days with short lectures, usually less than 30 minutes, and lectures were grouped according to their subject matter, each day dedicated to a different aspect. All the conferences were concentrated in the afternoon, which was a great success.

For this event, unlike other 100% online events, they opted to pre-record the conferences in order to obtain a more controlled result and avoid problems associated with live events. The conference was always accompanied by a space of 10 minutes dedicated to questions and answers. Besides, some of the conferences had an extra set of tests to check what was learned, even with the option of winning prizes. Although I personally did not use this element I think it is interesting and a good initiative.

Kotlin Event

The conferences were grouped as follows:

Day 1: General Overview
Day 2: Kotlin Libraries.
Day 3: Kotlin everywhere: Android, KMM, JS.
Day 4: Server-side Kotlin.

Day 1

The first talk was aimed to present the most important topics that would be discussed throughout the event, making reference to the subsequent talks.

The main topics discussed were:

  • The progress and current status of the new Kotlin compiler with a 4.5 times faster frontend.
  • The improvements in the type inference system with which they have fixed more than 300 issues.
  • Plans to support new features in Java 14 and Java 15.
  • Kotless a framework for serverless backends.
  • Kotlin multiplatform and its libraries for concurrency, serialization and dates.
  • The improvements in file size with the new compiler in KotlinJS. 
  • Future plans for WebAssembly.
  • The current status (beta) and improvement plans for KMM (Kotlin multiplatform mobile). 

The next conference focused on the Kotlin community and how to contribute to the project. Sharing statistics and usage, using early-access-programs (EAP), reporting problems or incompatibilities through YouTrack are some of the things that help improve and evolve the ecosystem.

Next came the talk “New Language Features in Kotlin 1.4” where the new language features in the latest version were discussed.

  • SAM (single abstract methods). This allows us to pass a lambda when a method receives by parameter an interface with a single method. This feature was already available with interfaces defined in Java and now we can do the same with interfaces defined in Kotlin with the following syntax: fun interface Action {}
  • Explicit mode is a validation process that we can activate from gradle that was meant for libraries creators and that allows to verify a set of recommendations: methods visibility, specifying return and so on.
  • Trailing commas. It allows to put a comma “,” at the end of a list of arguments, function declaration or class declaration (constructor).
  • Break and continue within when. Unlike the previous version, Kotlin 1.4 allows the use of continue within a when expression.
  • Mix of positional arguments and named arguments.
drawRectangle(
    width = 10, height = 20, color = Color.BLUE
)
drawRectangle(
    width = 10, height = 20, Color.BLUE
)
  • Improved type inference systems.
  • Unification of exceptions for nulls. In previous versions of Kotlin, depending on the context, different exceptions related to null could be launched. Now it has been unified in a single exception with the intention of being able to optimize certain checks at the compiler level, in the near future. 
  JSON in Kotlin: Comparing Options

The penultimate conference of the day was focused on the improvements made to the IDEs and the use of Kotlin. Improvements in auto-completion and code indexing among other things.

For further information: https://www.youtube.com/watch?v=-5ZjMwNzWrk

The talk that aroused the most interest

To finish we had what I would personally categorize as the highlight of the day and perhaps of the event. These are the next features of Kotlin.

Under the name “A look into the Future” Roman Elizarov brings together the most important themes that are about to come in the language, but first briefly reviewing the language milestones or key points on a historical level. The first version, the appearance of the coroutines, the compatibility with Javascript, Kotlin/Native etc.

In the near future, interoperability with more modern versions of Java will be enhanced to be able to use its Sealed Classes version and the Records (in essence very similar to a Kotlin data class).

For the more distant future they are focusing on the following ideas:

  • Companion namespaces: through a new keyword it would be possible to encapsulate variables (constants for example) or functions within the same concept without it representing a particular type. This new element could also be applied to the Kotlin extensions, namespace extensions.

Captura de pantalla 2020 10 28 a las 15.38.02

  • Multiple receivers: this feature would allow us to create an extension whose body has access to more than one context, that is, the extension is from two types at once. For this, a final syntax has not been defined yet, but they are working with the idea of using decorators. Decorator would be one more keyword of the language that could be added to a function and then, as an annotation (@), used in other functions. In the following example, taken from the presentation, we see that we use a @with annotation that is actually a decorator we have created. This decorator could also be an extension function on View and by using it on another extension allows us to have the two “contexts” in the body of the second extension.
  Online software architecture workshops that you can't miss

Captura de pantalla 2020 10 28 a las 15.36.08

This functionality is not only focused on the extension functions but with the decorators could simplify other situations.

  • Another new feature is to have different visibility for the same property (getters and setters). This in Android, would simplify the code we normally write to “hide” the mutable version of a LiveData to consumers.

Captura de pantalla 2020 10 28 a las 15.36.29

  • Finally, they are working on a syntax that would allow us to work with an immutable model but with the easy manipulation of a mutable structure.

Captura de pantalla 2020 10 28 a las 15.36.46

With this we would avoid having to make a .copy() every time we want to modify some value.

Captura de pantalla 2020 10 28 a las 15.37.03

This new keyword would unify the inline classes as otherwise there would be compatibility problems with Valhala project. So an inline class would become a value class with an annotation that would indicate to the compiler that it can be simplified to a primitive type (this annotation is not yet defined). 

Day 2

The second day focused on the Kotlin libraries.

At the beginning, it was coroutines turn where they focused on the debugger improvements and the new APIs recently added. ShareFlow and StateFlow.

The next talk focused on the serialization library and its first stable version. Kotlinx.Serialization is a multiplatform library that we can use in JVM, Native and JS.

In addition, a new library for date management, Kotlinx.Date-Time was also presented in another talk.  This is another cross-platform library that uses java.time for JVM, js-joda for Javascript and ThreeTen for native.

Apart from these talks there was also one focused on the new APIs added in the Kotlin standard library (stlib).

Day 3

Third day was focused on the use of Kotlin in frontend/mobile environments.

The first talk by Florina Muntenescu (from Google) focused on the initiatives of the Android team to maximize the virtues of Kotlin.

One example is Jetpack Compose, a library written entirely in Kotlin and whose dependence on the new compiler means that the two companies are working closely together. Apart from this library we also see that integration with coroutines is extended in all possible libraries: Room, Paging, DataStore…

  Kotlin Everywhere in Barcelona

Then we had two talks focused on KMM with a KotlinJS talk between these two. The first of the two KMM or Kotlin Multiplatform Mobile talks had a more introductory approach.

On the other hand, the KotlinJS talk was all about the improvements that the latest version of Kotlin has brought: interoperability with packages distributed by NPM and the generation of static definitions with the Dukat project that is still in an experimental phase.

Besides this, we have available the first version of kotlinx-nodejs that will allow us to make use of the node APIs from Kotlin.

With the arrival of the new compiler they hope to reduce the final size of JS code by using tree shaking through webpack, improve compatibility with Typescript and be able to use a Kotlin library in Typescript and vice versa.

To be able to test the new compiler we only have to add the following line to the gradles properties file.

kotlin.js.compiler=ir

Day 4

Finally, the fourth day was dedicated to backend development with Kotlin.

Talks about:

Conclusion

In my opinion, the highlight of this event was concentrated on the first day through the talk on the future of the language, which is why I have extended a bit more on that one. I find very interesting the direction the language is taking with new proposals and I look forward to seeing how they evolve (decorators, value-based class, namespaces).

The new compiler is a project that has been in progress for some time but whose repercussions deserve all the caution, and the advances shown indicate that we are close to a final version.

The initiatives in the “mobile” world do not fall short and it seems that KMM will be a project with a great future.

Now we just have to wait to see what Kotlin version 1.5 will bring.

Author

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Subscribe To Our Newsletter

Get updates from our latest tech findings

Have a challenging project?

We Can Work On It Together

apiumhub software development projects barcelona
Secured By miniOrange