-
-
Notifications
You must be signed in to change notification settings - Fork 382
Add Kotlin #373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Kotlin #373
Conversation
I really love Kotlin and all my projects with this library written in it but I think that it’s a really bad idea. I have experience writing a library in Kotlin with support for both languages, and it was terrible. I think this PR will disrupt the smooth usability experience for Java users and won't provide a lot of features for Kotlin users. (But fields instead of getters are cool, I really want it 👀) |
I have an idea (and I'm realizing it with my telegram-api-kindings, but not really fast 😅). Here is my view on Kotlin support:
|
That was unexpected 😁
I think we can try to do better. As a counter-example I can give OkHttp library that was rewritten in Kotlin and now is Kotlin first, and yet it's used in this library with no usability issues. I've seen your
They will bear it. I'm not the fan of the new module right now. If we keep main module in plain java then it would make sense to have additional
I think with no issues we can re-write models and everything else in Kotlin without affecting Java compatibility.
Yes, indeed! We are not limited by model only. Especially extensions will be very useful and handy (and won't require internal changes). kotlinx-serialization is questionable 😅 but better null-safety for kotlin is absolutely beatiful. In general, I don't see any big obstacles. Java users will have all the same they have now, and Kotlin users will get much more simplicity and hopefully safety. |
It should be more fun to write models in Kotlin.
Here is the initial Kotlin support with some request, models, and response converted.
We still need to keep it compatible with Java code, especially already existing.
So we either need to generate explicit getters (even if they're not needed in Kotlin but to have a Java getters without
get
) or define annotation for every field such as@get:JvmName("fileId")
.We can freely convert any existing models classes, but
TelegramBotTest
should at least compile without changes.It will act like a Java compatibility check.
Dear @anfanik you are very welcome to review and to share any ideas on improving it.