皇上,还记得我吗?我就是1999年那个Linux伊甸园啊-----24小时滚动更新开源资讯,全年无休!

Kotlin 1.2 发布,实现平台间共享代码

Kotlin 1.2 发布,实现平台间共享代码

Kotlin 1.2 发布了。多平台项目允许您从相同的代码库构建应用程序的多个层 – 后端,前端和 Android 应用程序。 这样的项目包含了独立于平台的代码的通用模块,以及特定平台(JVM 或 JS)的代码的特定模块,并且可以使用平台特定的库。 要从通用模块中调用特定于平台的代码,您可以指定预期的声明 – 所有平台特定模块需要提供实际实现的声明。

Kotlin 1.2 发布,实现平台间共享代码

如前所述,开发团队也在研究一系列通用库,以便将更多的逻辑转移到通用代码中:

  • kotlin.test, 在Kotlin 1.2开箱即用,只要编写一次测试就能在 JVM 和 JS 下运行;
  • kotlinx.html 支持同构渲染 – 使用相同的代码在后端和前端渲染 HTML;
  • kotlinx.serialization 允许您使用 JSON 或 ProtoBuf 作为序列化格式,轻松地将 Kotlin 对象封装在应用程序的不同层之间。

编译性能提升 25%,下图显示了使用 Kotlin 构建的两个大型 JetBrains 项目的编译时间差异:

Kotlin 1.2 发布,实现平台间共享代码

其他改进:

  • A more concise syntax for passing multiple arguments to an annotation (array literals);
  • Support for the lateinit modifier on top-level properties and local variables, as well as checking whether a lateinit variable is initialized;
  • Smarter smart casts and improved type inference in certain cases;
  • Compatibility of the standard library with the split package restrictions introduced in Java 9;
  • New kotlin.math package in the standard library;
  • New standard library functions for working with sequences and collections, including a set of functions for breaking a collection or sequence into potentially overlapping groups of a fixed size.

下载地址:

转自 http://www.oschina.net/news/91010/kotlin-1-2