Anyone know if there are any plan for Kotlin to su...
# server
f
Anyone know if there are any plan for Kotlin to support async await as well as coroutines, swift uses async await and C# has had it for a long time, async await is fairly easy to understand and keeps code clean, it would be great if it came to Kotlin so we could use the same paradigm in swift and kotlin
h
Do you mean Swift interoperability? Kotlin has
suspend
language support, which needs this https://github.com/Kotlin/kotlinx.coroutines library
f
No I was meaning support for the async await keywords to allow you to run async code while writing the code in a synchronous fashion.
Copy code
do {
        let result = try await getInvites(loggedOnUserId)
        invitesEnvironmentObject.replace(invites: result)
      } catch {

        showExceptionModal = true
      }
In swift I can write to call an async method
h
In Kotlin,
async
is called
suspend
.
For
await
, you need a CoroutineScope, which is provided by the library.
e
You can get short comparison and contrast with C# approach here https://m.youtube.com/watch?v=hb0hfHVWCS0
👍 1
f
I can do async code through coroutines, but I think that is a different approach than how C# and Swift do async await
Ok thanks, for the link, looks like I’ll have to learn coroutines
@elizarov cheers for your work on Kotlin, I’ve been a Java dev for years but for my startup chose kotlin as I far prefer the less verbose syntax
👍 2
j
Roman's KotlinConf videos detail why Kotlin uses another approach compared to C#. I highly recommend watching them to get a bigger picture.
☝️ 4
f
perfect thanks for the link that clears things up