我正在考虑将Java(Android)库移植到Kotlin.我真的很喜欢Kotlin,相对于Java的好处应该会减少库中的bug数量.

Since the library is targeting a resource constrained environment I'm worried that by porting the library to Kotlin there will be extra overhead.

Does a Kotlin library (distributed as .class files) introduce any runtime or extra overhead versus a Java library?

Will the resulting Android app be any larger or slower because of Kotlin?

推荐答案

Kotlin has many optimizations specifically that help Android. If you read through blog posts you can see how it has constantly reduced stdlib size, and amount of classes at every release.

Will the resulting Android app be any larger or slower because of Kotlin?

No

Does a Kotlin library (distributed as .class files) introduce any runtime or extra overhead versus a Java library?

标准库非常小,它的许多函数都是内联的,这意味着它们在编译后不存在,只是成为内联代码.Proguard也能处理很多事情.

Since the library is targeting a resource constrained environment I'm worried that by porting the library to Kotlin there will be extra overhead.

您没有定义哪些资源受到限制.Kotlin不会使用更多内存,也不会使用更多磁盘,而且stdlib很小.

我真的很喜欢Kotlin,与Java相比的好处应该可以减少库中的bug数量.

Kotlin is popular on Android for a reason, and you should take that as a sign that there are many more benefits than negatives. Really you can see this for yourself by having a small example in Java and small in Kotlin and compare the difference. Proguard both, have the same type of build pipeline.

Kotlin相关问答推荐

Kotlin -从列表中获取特定过滤器的唯一列表值

如何访问方法引用的接收者?

在Kotlin中求n个ClosedRange实例相交的最常用方法是什么?

有没有一种简单的方法来识别物体?

Kotlin Poet 的导入不明确

Kotlin 启动与启动(Dispatchers.Default)

Mixin 在 Jackson 中添加 defaultImpl 不起作用

Kotlin 中获取类简单名称的最佳实践

下拉通知面板时是否可以暂停Android中的任何视频(媒体播放器)应用程序?

在粘贴时将 java 转换为 kotlin

找不到 androidsdk.modules

API 'variant.getJavaCompile()' 已过时

如何使用 Coil 从 URL 获取位图?

Kotlin内联扩展属性

使用 Paging 3 时保存并保留 LazyColumn 滚动位置

Kotlin使用运行时断言进行空判断?

Spring Boot:更改属性占位符符号

将字符串转换为HashMap的最简单方法

lateinit 的 isInitialized 属性在伴随对象中不起作用

如何判断数据是否插入到房间数据库中