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 language support #2323
Conversation
Can one of the admins verify this patch? |
So a few things that concern me with this right now:
|
I echo Evan's concerns here. Can we get the benefit without the penalty? |
Yes. That should be possible. I'll take a look.
Those libraries in the
Sure. package io.shreyash.maths
import ...
@DesignerComponent(version = 1, nonVisible = true, category = ComponentCategory.EXTENSION, description = "", iconName = "")
@SimpleObject(external = true)
class Maths(container: ComponentContainer) : AndroidNonvisibleComponent(container.`$form`()) {
@SimpleFunction
fun Add(a: Int, b: Int): Int {
return a + b
}
} |
Yes, perhaps you're right. There's no benefit of this for an average App Inventor user. Although IMO, a slight increase (just ~400 to 500 KBs) in size won't be affect most of the users. But no worries, we can eliminate this issue by adding an annotation like Evan suggested to add the Kotlin Standard library to compiled apps only if it's needed. But from a developer's perspective, there's a big list of benefits. Here are some of them:
|
@ewpatton |
@shreyashsaitwal That would be acceptable. |
@ewpatton |
Great work! |
Just like every Kotlin program, extensions written in Kotlin also require the Kotlin Standard library. So yes, it will increase the compiled app's size. |
We could shrink the Kotlin stdlib's binary size by a significant margin! https://jakewharton.com/shrinking-a-kotlin-binary/ We need R8 support in order to do that. |
@pavi2410 That will only hold for compiled apps (with the best optimization being not including Kotlin at all if no components call for it). By its nature the Companion app must include everything because it might be reachable by a yet-to-be loaded extension. |
Do we really care about the companion size? The latest version is at 15.60 MB. A ~2MB increment doesn't sound too much for the companion, does it? |
@StormiFire You can still access container.`$add`(this) |
I tried that way and still got an error... That is why I suggested the new class. @pavi2410 did you also include EditI redact my suggested class, I did not see |
Wdym by "did you also include (this)?" This is the invocation of |
@StormiFire AndroidNonvisibleComponent(container.`$form`()) |
@ewpatton I'd like to know if there's anything blocking this PR. It's been a long time since I opened it. I don't want it to remain in this sort of abandoned state forever like rest of those PRs. |
@shreyashsaitwal You've updated libraries and we currently don't have time to test those updates to ensure they don't break anything. Generally we only update core libraries as part of the SDK update during the summer as this is the time of least usage during the year. If you want this to be merged before then, I would propose that you revert any updated libraries and just focus on the additions needed for Kotlin as this would minimize what needs to be evaluated. @pavi2410 R8 doesn't solve the companion size issue as you can't really do dead code elimination since every public API could be called by extensions. |
This reverts commit 97753f5.
Closing this PR as I think it'd be pretty hard for AI to keep up with the latest updates in the Kotlin language. IMO, it's best to have extension builders implement support for Kotlin. It does increases the AIX size significantly, however, using ProGuard you can strip it off by almost 90%. As of now, only Rush supports developing extensions in Kotlin, but it should be pretty straightforward to implement it in extension-template following changes in this PR. |
With this change, it'll now be possible to write components (and extensions!) in Kotlin. The Android ecosystem is moving towards Kotlin at a fast pace and with Google promoting it every now and then, it'd be a huge loss to not worry about it. Being Kotlin ready will help App Inventor in the long run and explore amazing Kotlin exclusive Android features such as Jetpack Compose.
Along with this, I've also bumped the versions of
androidx.core
andandroidx.arch.core
packages as the ones currently in use are very old. Although this ain't related to the Kotlin support in general, it will help solve the issues extension devs face while using features that were added in later versions of these libs.What will change?