josephivie
08/22/2019, 5:42 AM.kts
files will be with this script runner, why is it not default? The complexity of use is keeping scripting from becoming widely useful. I'd like the equivalent python script.py
, and I'd like it to be part of installing Kotlin. Until it's that simple, I can't rely on distributing .kts
files to others as a consistent, portable, easy way of giving other people scripts.
I know kscript
exists, but it only supports *nix.gildor
08/22/2019, 5:52 AMkotlin script.kts
instead of existing
kotlinc -script script.kts
gildor
08/22/2019, 5:54 AMpython
also doesn’t support remote dependenciesjosephivie
08/22/2019, 5:54 AMkotlinc -script script.kts
(or even simpler)
instead of
kotlinc -cp some-jar-i-downloaded-separately.jar -script sample.main.kts
josephivie
08/22/2019, 5:55 AMgildor
08/22/2019, 5:55 AMkotlinc -script script.kts
already worskgildor
08/22/2019, 5:56 AMinstall dependencies globallyLooks as a bad solution for me Every time when I work with python global dependencies it was a mess
josephivie
08/22/2019, 5:56 AMgildor
08/22/2019, 5:56 AMjosephivie
08/22/2019, 5:56 AMgildor
08/22/2019, 5:57 AMjosephivie
08/22/2019, 5:57 AMgildor
08/22/2019, 5:57 AMjosephivie
08/22/2019, 5:57 AMgildor
08/22/2019, 5:57 AMgildor
08/22/2019, 5:57 AMgildor
08/22/2019, 5:57 AMgildor
08/22/2019, 5:58 AMgildor
08/22/2019, 5:58 AMgildor
08/22/2019, 5:59 AMgildor
08/22/2019, 5:59 AMgildor
08/22/2019, 6:01 AMjosephivie
08/22/2019, 6:02 AM.kts
file to be runnable with kotlinc -script something.kts
, the definition of .kts
is vague, and it will always be irritating to figure out how to run that script. Maybe we need another file extension to denote that its runnable normally?gildor
08/22/2019, 6:02 AMdefinition ofWhy so?is vague.kts
gildor
08/22/2019, 6:02 AMgildor
08/22/2019, 6:03 AMjosephivie
08/22/2019, 6:05 AM.kts
without additional context.
A .sh
is simple - it is run with shell. There's no questions about it.
If a .kts
might require a certain scripting module in order to run, then information about how it works is incomplete without some extra documentation. On the other hand, if .kts
files were always run with the same runner, we wouldn't have to wonder.
Perhaps we need a .skt
(standalone kotlin) extension to indicate that it will work with just the standard script runner.gildor
08/22/2019, 6:05 AMAIt’s just a convention, you also have to use very particular command to run itis simple - it is run with shell..sh
josephivie
08/22/2019, 6:05 AM.gradle.kts
gildor
08/22/2019, 6:06 AMgildor
08/22/2019, 6:06 AMgildor
08/22/2019, 6:06 AMgildor
08/22/2019, 6:07 AMkotlinc -script
, no magicgildor
08/22/2019, 6:07 AMjosephivie
08/22/2019, 6:08 AMjosephivie
08/22/2019, 6:09 AMkotlinc
is set up right now encourages special custom runners. That's something that can be left to people using the library from Maven directly.gildor
08/22/2019, 6:09 AMspecial embedded scriptingNot only embbedded! That’s the whole point. .something.kts is convention that allows to implement own script definition
gildor
08/22/2019, 6:10 AMjosephivie
08/22/2019, 6:10 AM.something
before the .kts
, I'm cool.gildor
08/22/2019, 6:10 AMjosephivie
08/22/2019, 6:11 AMkotlin something.kts
right now.gildor
08/22/2019, 6:21 AMeveryone always adds theaddition extension means that user of this script should somehow get script definition for it, this is what happening in.something
kotlinc -cp kotlin-main-kts-1.3.41.jar
So I see 2 parts of this story:
1. Support of dependencies. I see .main.kts
just as temporary solution/proof of concept. Essentially everyone want dependencies in their scripts, it should be supported at least with special key for kotlinc
2. Discoverability for custom script definition. if you want to provide own kinds of scripting and call it josepth.kts
, you can distribute this script and script definition, but how user can run it. It’s not so simple question.
Current solution, you just download script definition jar and add it to classpath (-cp key for kotlinc or even just add to yor jre\lib\ext directory, which is essentially become global dependency, nasty but works)
I would like to have improved discoverability for this, like script author can specify ScriptDefinition dependency using some default annotation, or even install them globally.
This is why I recommend you, if you interested in this feature, comment scripting KEEP. At least with your use casejosephivie
08/22/2019, 6:30 AMkotlin-main-kts
jar, that it would become standard to always use some kind of special script definition jar, which would muddy what a .kts
was - with no useful default, there would be no useful meaning to having a .kts
extension at all. Distributing them would be a nightmare, as everyone has to install custom script definitions for most scripts.
For point 2, it might be good if there was a general registry mapping `.something.kts`extensions to their definitions.gildor
08/22/2019, 6:31 AMjosephivie
08/22/2019, 6:32 AMgildor
08/22/2019, 6:32 AMjosephivie
08/22/2019, 6:32 AMjosephivie
08/22/2019, 6:33 AMgildor
08/22/2019, 6:33 AMgildor
08/22/2019, 6:34 AMilya.chernikov
08/22/2019, 10:24 AMkash
and kscript
, and maybe we just need to provide all the APIs and internals to make it easy to create such shells.
But it is clear that there is a demand for the standard out-of-box scripting, so we’re thinking about it, but how it will be approached is not yet clear.
The kotlin-main-kts
is an experiment to provide a prototype of a standard scripting, and it seems that it is a baseline of what people are expecting. So maybe it will become part of the standard scripting eventually.cedric
08/22/2019, 2:52 PMkash.kts
are run as native commands, e.g. a.kash.kts
can be invoked with just a
(you just need to tell Kash where to find your scripts). Also, remote dependencies in script files are supported, so you can use Maven coordinates directly inside your scripts