https://kotlinlang.org logo
#ktor
Title
# ktor
k

Kamo Spertsyan

11/08/2021, 8:33 AM
Hello! I've got weird but interesting for me question about ktor client library. Would be glad to hear developers team answers. Had you thought about giving some additional API besides coroutines one? If had but decided not to do it, then why? (I don't need different API, just want to understand your position in this question) Thank you! Looking forward for your answer.
e

e5l

11/08/2021, 8:57 AM
Hey @Kamo Spertsyan, thanks for the question.
Could you give me an example of what API you expect?
a

andylamax

11/08/2021, 9:07 AM
maybe a callback based api instead?
k

Kamo Spertsyan

11/08/2021, 9:08 AM
Yes, callback based one
e

e5l

11/08/2021, 9:09 AM
No, I'm sorry. We don't have any plans about callback based API
k

Kamo Spertsyan

11/08/2021, 9:09 AM
Could you explain a bit your position please?
e

e5l

11/08/2021, 9:14 AM
Sure. Ktor client is made in a way that you can replace any blocking client without much effort: you don't have to restructure lots of code with callbacks and keep the logic linear. In the same time it's backed by coroutines, it allows to make implementation asynchronous.
I still not sure that I understand the question right: It's not clear for me what is a benefit of using callbacks instead of linear logic
k

Kamo Spertsyan

11/08/2021, 9:18 AM
I'm exploring different libraries with asynchronous api, so I'm just interested in the way you design ktor library. Coroutines API is not a problem) One last question please, want to clarify if I've correctly understood library. Are users able to use ktor without using coroutines in their projects?
a

andylamax

11/08/2021, 9:18 AM
Sorry for hijacking the thread. But IMHO, there is too much benefit of using linear logic vs callbacks. But for some platforms (Kotlin/JS), the cost of linear logic is so high that would make me settle with a callback based API for my multiplatform projects
e

e5l

11/08/2021, 9:22 AM
@Kamo Spertsyan, nope there is no way
k

Kamo Spertsyan

11/08/2021, 9:22 AM
But for some platforms (Kotlin/JS), the cost of linear logic is so high that would make me settle with a callback based API for my multiplatform projects
And you build your own proxy with callback api over the coroutine-based libraries like ktor, right?
@e5l, okay, thank you very much for your answers!
e

e5l

11/08/2021, 9:23 AM
@anton.bannykh @Kamo Spertsyan please get in touch to discuss this
No problem! Thanks for the good question
a

andylamax

11/08/2021, 9:31 AM
And you build your own proxy with callback api over the coroutine-based libraries like ktor, right?
Not really, just have a pure callback based on common code, and have something like suspending await methods, which one can opt to use over the default suspending ones. So, ktor-client-core becomes purely callback based, not depending on coroutines at all, and have something like ktor-client-ktx wich depends on coroutines and has those methods. Makes it easy to write common code independent of coroutines and use it in optionally in platforms like kotlin/jvm or kotlin/native
🙏 1
👍 1
a

anton.bannykh

11/08/2021, 10:19 AM
@andylamax are you avoiding coroutine-based API due to increased code size, or performance considerations?
a

andylamax

11/08/2021, 3:30 PM
@anton.bannykh affirmative
a

anton.bannykh

11/09/2021, 7:22 AM
@andylamax So both then? Could you share any numbers?
a

andylamax

11/10/2021, 3:52 AM
Let me work on the numbers, I will share them by the end of the day
🙏 1
🙏 1
a

anton.bannykh

11/12/2021, 10:20 AM
@andylamax friendly ping 😃
2 Views