First of all, many thanks to the Kotlin team for bringing the JVM into a modern era of development.
After migrating all my Android code to Kotlin, I tried to use Kotlin as a scripting language.
I wrote a simple helloWorld.kts script:
#!/usr/bin/env kotlinc -script
println(“Hello world”)
When running this script with kotlinc - script, I realized that the startup time is incredibly slow:
time kotlinc -script helloWorld.kts
Hello world
real 0m2.417s
2.417 seconds to print hello world…
It seems that most of this time is spent for compiling the Kotlin script.
The following produces a HelloWorld.class without running the script:
time kotlinc helloWorld.kts
real 0m2.499s
Moreover, If I use kotlin instead of kotlinc, then it does not work at all:
kotlin helloWorld.kts
error: running Kotlin scripts is not yet supported
Compare this to Java:
time sh -c ‘javac HelloWorld.java && java HelloWorld’
Hello world
real 0m0.433s
I use Ubuntu 18.04.
I installed kotlinc with sudo snap install --classic kotlin.
This yields:
kotlinc -version
info: kotlinc-jvm 1.3.61 (JRE 1.8.0_222-8u222-b10-1ubuntu1~18.04.1-b10)
This leads me to the questions:
Did I miss a step to setup?
What is the current state of Kotlin scripting support?
Can we expect Kotlin to be a reasonable scripting language?