Server-side async/await with coroutines

It looks very promising!

I was looking into its integration with Kotlin coroutines, and one thing I find odd is, there is a lot of usage of awaitResult primitive, e.g. in https://github.com/vert-x3/vertx-examples/blob/master/kotlin-examples/coroutines/src/main/kotlin/movierating/App.kt:

    val result = awaitResult<ResultSet> { client.queryWithParams("SELECT TITLE FROM MOVIE WHERE ID=?", json { array(id) }, it) }

I was wondering why is there a need for it in Kotlin from API standpoint (understand it has to be like that in e.g. Java).

With Kotlin coroutines, it should be possible to write:

    val result = client.queryWithParams("SELECT TITLE FROM MOVIE WHERE ID=?", json { array(id) })

and have queryWithParams a suspending function. Wouldn’t such code be more natural?

Consider this:

class CoroutinesSimpleTest {
	@Test
	fun test() = runBlocking {
		val l = List(60) {
			async {
				delay(1000L)
			}
		}

		l.forEach { it.await() }
	}
}

This code will take 1s to execute in Kotlin, but 60s in JavaScript or Hack. The default settings are not the same (in terms of when a coroutine is started).

I’m not advocating for either (I have no experience with Kotlin’s approach), but I’m curious about the reasons behind the default