参考资料和站点
https://github.com/JetBrains/kotlin/releases/tag/v1.0.6 下载compiler,如果IDEA已经安装了,不需要安装即可直接使用
http://kotlinlang.org/docs/reference/
http://kotlinlang.org/docs/kotlin-docs.pdf 这个参考很全面
http://kotlinlang.org/api/latest/jvm/stdlib/index.html 标准库
http://kotlinlang.org/docs/reference/idioms.html 惯用法
https://github.com/Kotlin/kotlin-koans 例子练习
https://blog.jetbrains.com/kotlin 官方blog
https://blog.jetbrains.com/kotlin/category/releases/ 发布历史
https://github.com/JetBrains/kotlin-examples 例子
https://github.com/JetBrains/kotlin-benchmarks 和JAVA的性能比较
http://www.println.net/ 国内的短视频
Kotlin Benchmarks
https://github.com/JetBrains/kotlin-benchmarks
报告结果拷贝到本机的IIS上,并能够获取Google等Javascript CDN,才可看到报告【这里有个很好的性能测试工具使用参考JMH org.openjdk.jmh】
Comparison with Baseline
For multicolumn search separate subqueries with semicolon: "IntListBenchmark;manual;1000"
Difference is current score minus baseline score. Positive values are regressions, negative are gains.
Switch to comparison with Java
Search:
ClassArrayBenchmark.copy |
10 |
0.05 |
us/op |
± 2.60% (0.00) |
||
ClassArrayBenchmark.copy |
1000 |
5.92 |
us/op |
± 0.53% (0.03) |
-0.26 |
-4.23% |
ClassArrayBenchmark.copy |
100000 |
634.74 |
us/op |
± 7.90% (50.16) |
||
ClassArrayBenchmark.copyManual |
10 |
0.06 |
us/op |
± 2.92% (0.00) |
||
ClassArrayBenchmark.copyManual |
1000 |
8.03 |
us/op |
± 1.82% (0.15) |
+0.16 |
+2.06% |
ClassArrayBenchmark.copyManual |
100000 |
802.06 |
us/op |
± 0.71% (5.70) |
||
ClassArrayBenchmark.countFiltered |
10 |
0.40 |
us/op |
± 1.12% (0.00) |
||
ClassArrayBenchmark.countFiltered |
1000 |
46.94 |
us/op |
± 3.07% (1.44) |
||
ClassArrayBenchmark.countFiltered |
100000 |
5670.62 |
us/op |
± 3.57% (202.40) |
||
ClassArrayBenchmark.countFilteredLocal |
10 |
0.39 |
us/op |
± 0.84% (0.00) |
-0.01 |
-2.21% |
ClassArrayBenchmark.countFilteredLocal |
1000 |
46.44 |
us/op |
± 1.99% (0.92) |
||
ClassArrayBenchmark.countFilteredLocal |
100000 |
5599.66 |
us/op |
± 1.20% (67.01) |
-125.05 |
-2.18% |
ClassArrayBenchmark.countFilteredManual |
10 |
0.39 |
us/op |
± 1.93% (0.01) |
||
ClassArrayBenchmark.countFilteredManual |
1000 |
46.28 |
us/op |
± 1.07% (0.50) |
||
ClassArrayBenchmark.countFilteredManual |
100000 |
5638.10 |
us/op |
± 1.20% (67.56) |
Kotlin Compiler
Jetbrains Idea下的默认kotlin安装
独立的compiler包下载解压的结果
E:\tool\kotlin\kotlinc 的目录
[.] [..] [bin] build.txt [lib] [license]
1 个文件 5 字节
E:\tool\kotlin\kotlinc\bin 的目录
[.] [..] kotlin kotlin.bat kotlinc kotlinc-js kotlinc-js.bat kotlinc-jvm
kotlinc-jvm.bat kotlinc.bat
8 个文件 7,900 字节
E:\tool\kotlin\kotlinc\lib 的目录
[.] [..] allopen-compiler-plugin.jar android-extensions-compiler.jar
kotlin-annotation-processing.jar kotlin-ant.jar kotlin-build-common-test.jar kotlin-build-common.jar
kotlin-compiler.jar kotlin-daemon-client.jar kotlin-jslib-sources.jar kotlin-jslib.jar
kotlin-preloader.jar kotlin-reflect.jar kotlin-runner.jar kotlin-runtime-sources.jar
kotlin-runtime.jar kotlin-test.jar noarg-compiler-plugin.jar
17 个文件 25,843,381 字节
E:\tool\kotlin\kotlinc\license 的目录
[.] [..] LICENSE.txt NOTICE.txt [third_party]
2 个文件 1,083 字节
E:\tool\kotlin\kotlinc\license\third_party 的目录
[.] [..] args4j_LICENSE.txt asm_license.txt closure-compiler_LICENSE.txt
dart_LICENSE.txt jshashtable_license.txt json_LICENSE.txt maven_LICENSE.txt pcollections_LICENSE.txt
prototype_license.txt rhino_LICENSE.txt
10 个文件 78,237 字节
2者是一样的,因此如果安装了idea的话,kotlin的环境默认就是可用的
if "%_KOTLIN_COMPILER%"=="" set _KOTLIN_COMPILER=org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
if not "%JAVA_HOME%"=="" (
if exist "%JAVA_HOME%\bin\java.exe" set "_JAVACMD=%JAVA_HOME%\bin\java.exe"
)
if "%_JAVACMD%"=="" set _JAVACMD=java
rem We use the value of the JAVA_OPTS environment variable if defined
set _JAVA_OPTS=-Xmx256M -Xms32M
if not "%_KOTLIN_RUNNER%"=="" (
"%_JAVACMD%" %_JAVA_OPTS% "-Dkotlin.home=%_KOTLIN_HOME%" -cp "%_KOTLIN_HOME%\lib\kotlin-runner.jar" ^
org.jetbrains.kotlin.runner.Main %*
) else (
"%_JAVACMD%" %_JAVA_OPTS% -noverify -cp "%_KOTLIN_HOME%\lib\kotlin-preloader.jar" ^
org.jetbrains.kotlin.preloading.Preloader -cp "%_KOTLIN_HOME%\lib\kotlin-compiler.jar" ^
%_KOTLIN_COMPILER% %*
)
直接从命令行运行kotlin,最终的结果是转换成JAVA字节码的
kotlinc HelloWorld.kt -include-runtime -d HelloWorld.jar
$ java -jar HelloWorld.jar
kotlinc HelloWorld.kt -d HelloWorld.jar
java -cp $KOTLIN_HOME/lib/kotlin-runtime.jar:HelloWorld.jar HelloWorldKt
脚本方式执行
$ kotlinc-jvm -cp joda-time-2.9.4/joda-time-2.9.4.jar
Welcome to Kotlin version 1.1-M04 (JRE 1.8.0_66-internal-b17)
Type :help for help, :quit for quit
>>> import org.joda.time.DateTime
>>> DateTime.now()
kotlin-docs
http://kotlinlang.org/docs/kotlin-docs.pdf 152页,这个参考比较全
Kotlin For Android
《Kotlin for android Developers》 中文翻译 关于在android下的开发,使用kotlin可以大幅度的简化代码的编写