Kotlin 1.0 RC 发布,基于 JVM 的编程语言

oschina
 oschina
发布于 2016年02月05日
收藏 3

Kotlin 1.0 RC 发布,更新如下:

  • Language

    • new @delegate: use-site target for annotation (e.g. @delegate:Transient)

    • private top-level Kotlin classes should be compiled to package private java classes

    • unfinished multiline comment is an error

    • previously deprecated language constructs are now errors

    • type ckecking for use-site variance fixed

    • generic functions are compared for specificity through solving a constraint system

    • having multiple vararg parameters for one function is prohibited

    • super-calls to functions with default parameters are prohibited (pass all arguments explicitly)

    • implicit receiver behavior fixed

    • as-import removes original names if they were imported before

    • user code is not allowed in kotlin.** packages

    • type parameters of extension properties allowed to be indirectly used by the receiver type

    • members of private classes can-not be accessed from non-private inline functions

  • Java interop

    • forEach from Kotlin's library is preferred to forEach from java.lang.Iterable

    • synthesized declarations (like JavaBeans properties and SAM-converted methods) are now resolved on par with members

    • support added for Java setters that return values

    • previously depreacted Java declarations removed from generated code

    • private setters allowed for lateinit properties

    • wildcards are not generated for redundant type projections (use List<@JvmWildcard Foo> instead of List<out Foo>)

    • @Nullable/@NotNull annotations from different standard Java packages recognized (javax.annotations, Guava, Android, etc)

  • Standard Library

    • diagnostics for multiple conflicting Kotlin runtime versions in classpath

    • some functions have been made inline

    • many inline functions (most of them one-liners) can no longer be called from Java code. This will help us reduce the size of the runtime library in the future.

    • library code rearranged into more granular packages (no source changes should be required)

    • associate and associateBy are added to aid construction of maps associate and associateBy (instead of toMap/toMapBy)

    • groupBy with key- and value-selector functions

    • Map.getOrElse() and Map.getOrPut() now treat keys associated with null values as missing.

    • Map.getOrImplicitDefault() has been made internal

    • mutableListOf, mutableSetOf, mutableMapOf added to construct mutable collections. linkedListOf is deprecated

    • toMutableList added instead of toArrayList. The latter is deprecated

    • kotlin.system.exitProcess instead of System.exit

    • File.deleteRecursively only returns false in case of incomplete deletion

    • File.copyRecursively allows overwriting by specifying argument overwrite=true

    • changed File.copyTo behavior to be like Files.copy from JDK8.

    • more specific return type for File.inputStream, File.outputStream, String.byteInputStream.

    • IO utility functions taking charset name as a string are deprecated, use ones with Charset parameter.

    • File.useLines and Reader.readLines are introduced

    • File.(buffered)reader/writer now return less specific InputStreamReader/OutputStreamWriter and use UTF-8 encoding by default

    • Sequence and Iterable SAM constructor-like functions

    • Comparator- and comparison-related functions are moved to kotlin.comparisons package (not imported by default)

    • new properties in MatchResult: groupValues and destructured — provided for easier handling of regular expression match results

    • Lazy is now an interface open for implementation

    • kotlin.system.measureTimeNano renamed to measureNanoTime.

    • plusElement and minusElement functions as a synonyms for list + element and list - element.

    • kotlin.test.assertFailsWith with Class<T> parameter is deprecated, use an overload with KClass<T>.

    • toLinkedMap is deprecated.

    • UTF_32 charset properties added to Chatsets

  • Tools

    • To enable Android Extensions, use: apply plugin: 'kotlin-android-extensions'

  • IDE

    • Intention to replace iteration over map entries with a loop using a destructuring declaration

    • Inspection and quickfix to cleanup redundant visibility modifiers

    • Inspection to replace 'assert' calls checking that a variable is not null with !! or ?: error(...)

    • Show "Kotlin not configured" notification when opening a .kt file in the IDE if the Kotlin runtime is not configured for the corresponding module

    • Action to generate the toString() method

    • Support for implementing members by primary constructor parameters

    • Parameter info popup works for showing type parameters

    • Completion offers name variants based on unresolved identifiers in current file

    • Quickfix for adding missing branches to a when expression

    • Support for moving nested classes to the upper level or into another top-level class

    • @Suppress now works for IDE inspections

详情请看:发行说明

下载:here

Kotlin 是一个基于 JVM 的新的编程语言,由 JetBrains 开发。

其主要设计目标:

  • 创建一种兼容Java的语言

  • 让它比Java更安全,能够静态检测常见的陷阱。如:引用空指针

  • 让 它比Java更简洁,通过支持variable type inference,higher-order functions (closures),extension functions,mixins and first-class delegation等实现。

  • 让它比最成熟的竞争对手Scala语言更加简单。

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处,尊重他人劳动共创开源社区。
转载请注明:文章转载自 OSCHINA 社区 [http://www.oschina.net]
本文标题:Kotlin 1.0 RC 发布,基于 JVM 的编程语言
加载中

最新评论(6

arden
arden
1.0 已经发布了。
绝望生鱼片
绝望生鱼片
终于等到RC了!直接拿来开发服务端程序。
chenwenli
chenwenli

引用来自“回去干活”的评论

给我的感觉就是把语法优化了一下,还要兼容java,变化真心不是太大.最重要的是google不一定支持这玩意.
毕竟dart也是一个很优秀的语言,用来开发android,网页都是没啥问题.
dart好像没办法做推广啊~~没有大公司采用~
MarvinGuo
MarvinGuo
试用了一下,有可能以后会在项目中全面启用
回去干活
回去干活
给我的感觉就是把语法优化了一下,还要兼容java,变化真心不是太大.最重要的是google不一定支持这玩意.
毕竟dart也是一个很优秀的语言,用来开发android,网页都是没啥问题.
imknown
imknown
用它做 android 还是 不错的
返回顶部
顶部