Why there are no concurrency keywords in Kotlin?

Kotlin 1.1 with Coroutines was released and it brings with it async..await! Read more about it in Kotlin reference docs, Kotlinx Coroutines library and this great in depth Couroutines by Example

Outside of the Kotlin Coroutines, you have these options:

  • the Kovenant library adds Promises to Kotlin
  • the Quasar library provides light-weight threads and continuations
  • @Synchronized and @Volatile annotations which map directly to the same keywords in Java
  • synchronized blocks which in Kotlin come from an inline function synchronized().
  • Kotlin has a Kotlin.concurrent package and extensions with new functions and also extensions to JDK classes.
  • you can access anything in the java.util.concurrent package such as ConcurrentHashMap, CountdownLatch, CyclicBarrier, Semaphore, ...
  • you can access anything in the java.util.concurrent.locks package and Kotlin has extensions for a few of these including the cool withLock() extension function and similar read/write extensions for ReentrantReadWriteLock.
  • you can access anything in the java.util.concurrent.atomic package such as AtomicReference, AtomicLong, ...
  • you can use wait and notify on objects

You have everything Java has and more. Your phrase "synchronization and locks" is satisfied by the list above, and then you have even more and without language changes. Any language features would only make it a bit prettier.

So you can have 100% Kotlin code, using the small Kotlin runtime, the JVM runtime from the JDK, and any other JVM library you want to use. No need for Java code, just Java (as-in JVM) libraries.

A quick sample of some features:

class SomethingSyncd {
    @Synchronized fun syncFoo() {

    }

    val myLock = Any()

    fun foo() {
        synchronized(myLock) {
            // ... code
        }
    }

    @Volatile var thing = mapOf(...)
}

I'll answer my own question since actual answer to my question was somewhere deep in kotlin discussions.

What confused me at the time comming from java was that concurrency keywords were not language keywords they were annotations? to me it seemed strange that important concepts like synchronization were handled trough annotation, but now it makes perfect sense. Kotlin is going in the direction of being platform agnostic language, its not going to only work on jvm but pretty much anything. So synchronized and volatile were very specific to jvm, they might not be needed in javascript for example.

In a nutshell kotlin has everything java has (except package visibility) and much more, a huge difference that no other language has is coroutines. But there is nothing you can write in java that you cant do in kotlin... (as far as i am aware)