Open linux-china opened 2 years ago
shouldn't we be able to treat .kst like we treat .jsh ? skips compile and pass it to jshell/kotlin directly ?
@maxandersen I think main reason is about performance. It's very slow to execute Kotlin script by kotlin CLI, and compare as following:
kotlin hello.kts 6.50s user 0.47s system 198% cpu 3.522 total
java -Dkts=Hello -classpath com.example.jbang.CompiledKtsRunner 0.11s user 0.04s system 33% cpu 0.436 total
This is the main reason that kscript adopts compile/jar solution, and not to use kotlin cli to execute script.
Add Kotlin script(kts) support for jbang because logic to run kts is different with kt source file.
kotlinc hello.kts
and get Hello.classjava -Dkts=Hello -classpath hello.kts.f2adcb7.jar:kts-runner-1.0.0.jar com.example.jbang.CompiledKtsRunner
com.example.jbang:kts-runner:1.0.0"
is Maven artifact for kts wrapper class.jbang hello.kts
to run kts file.