additionally, are Kotlin scratches stable enough t...
# scripting
a
additionally, are Kotlin scratches stable enough to be an alternative to Nashorn for the reason of having interpreted code instead of compiled? (for the purpose of hot swapping)
g
scratches? Like “scratch files”? How does it related to Nashorn?
a
they can both be run from Java ScriptEngine
g
I'm a bit confused, because there is Kotlin Scratch files feature in IDEA, that allows to write Kotlin script and run, but it has nothing to do with JS, because scripting is for now JVM only feature
g
This is not a scratch, this is Kotlin scripting
And it is not running on JS, for now this is JVM API
And this code is not interpreted, it actually compiled, just compiled on runtime
a
ah interesting
@gildor what is the point of kts files then if they are compiled?
g
You can take Kotlin source code and run it as script on runtime, but to run it compiler will compile it before run
Also also scripts are different in terms of syntax: you don't need main method, it just executing sequentially, you control runtime of the script environment: provide default imports, environment variables, classpath etc
Original KEEP proposal contains a lot of use cases and provides rationale: https://github.com/Kotlin/KEEP/blob/scripting/proposals/scripting-support.md
In general use interpretation instead of compilation would give some use cases, but the problem that Kotlin interpreter doesn't exist, there is only compiler