Home » JVM Languages » Kotlin

Kotlin

5 Kotlin Features That Every Android App Developer Must Know

Java is considered to be the heart of the Android operating system and so for every Android developer, there is hardly any alternative than knowing Java. Well, at last, a superb alternative to Java has appeared with a lot of value packed within. Kotlin is a new programming language comes as a better and more effective alternative to Java for ...

Read More »

Water Pouring Problem with Kotlin and Vavr

The first time I saw the Water Pouring Problem being programmatically solved was the excellentlectures on functional Programming by Martin Odersky on Coursera. The solution demonstrates the power oflazy evaluation in Streams with Scala. Solving Water Pouring Problem using Kotlin I wanted to explore how I can rewrite the solution described by Martin Odersky using Kotlin and I realized two ...

Read More »

Testing exceptions in Kotlin with assertFailsWith

I wanted to write this short post to highlight the assertFailsWith function available to Kotlin that makes testing exceptions a bit easier. Testing exceptions isn’t something fancy or new to JVM languages (from now on I will use Java for comparisons) but Kotlin comes with the nice extra benefit of providing this functionality as part of its standard library. Comparing ...

Read More »

Storing when block subject in a variable

Super short post, on a change introduced in Kotlin 1.3 (yes I know it has been out for a while now). We will take a quick look at capturing the subject of a when block into a scoped variable. This is a quality of life improvement that saves a line or so of code while making the role of the ...

Read More »

Comparing Kotlin performance with Graal and C2

You may have heard of Graal, the new JIT compiler for the JVM written in Java. It is available inside the JDK since Java10 and in the future will probably become the standard of the JDK. If you are interested, you can find more information here: https://www.infoq.com/articles/Graal-Java-JIT-Compiler In the last year I mostly worked with Kotlin and as personal project I ...

Read More »

Testing Kotlin with Spock Part 3 – Interface default method

Kotlin allows you to put method implementation in an interface. The same mechanism can be found in Java interfaces as default methods (and also Groovy or Scala traits). Let’s see the difference between the Kotlin and Java default methods in interface by testing it with Groovy and Spock. What do we want to test? We often have an interface for ...

Read More »

Kotlin DSL: from Theory to Practice

I’ll try to explain the language syntax as simple as possible, however, the article still appeals to developers who consider Kotlin as a language for custom DSL building. At the end of the article I’ll mention Kotlin drawbacks worth taking into account. The presented code snippets are relevant for Kotlin version 1.2.0 and are available on GitHub. What is DSL? ...

Read More »