looking at Kotlin’s docs and how scripting is desc...
# scripting
p
looking at Kotlin’s docs and how scripting is described here: I found https://kotlinlang.org/docs/custom-script-deps-tutorial.html which one can find by going through “Platforms -> Scripting”. It describes a rather niche use case when someone wants to create its own scripting host, while I think a more common use case is having stand-alone .kts or .main.kts scripts. It’s possible right away, without creating any custom project. Would you be fine if this piece of docs first of all mentioned the more mainstream use case? I could propose a change there.
plus1 5
+ according to https://kotlinlang.org/docs/components-stability.html#current-stability-of-kotlin-components, scripting is not experimental (as the docs say), it’s at least alpha
@Vampire WDYT?
v
Probably more a sibling page under "Platforms -> Scripting" that also could come first. But yeah, could make sense at that place. I think the standard supported
kts
scripts are mainly documented when it comes to the CLI, as that is the way to start them. Either by manually calling the CLI, or for *nix to have a shebang line that runs the script with the given CLI, but essentially it is still running the Kotlin CLI with the file as argument. https://kotlinlang.org/docs/command-line.html#run-scripts https://kotlinlang.org/docs/compiler-reference.html#script
thank you color 2
p
oh ok, so there’s something in the docs on such stand-alone scripts, just not that easily discoverable as I’d expect. I’ll try to consolidate it somehow
v
Yeah, I think there is also very (i.e. too) little information about
main.kts
scripts and their possibilities, like using Repository, DependsOn, Import and so on.
👍 2
💯 1
p
proposed changes • rename “Get started with Kotlin custom scripting - tutorial” to “Creating a custom Kotlin scripting host - tutorial” • add another item under Platforms -> Scripts, next to the above “tutorial” item, called “Create standalone Kotlin scripts” ◦ describe the basics + all features not documented yet in the docs like DependsOn, Repository, shebang, .kts vs .main.kts and so on • in https://kotlinlang.org/docs/command-line.html#run-scripts and https://kotlinlang.org/docs/compiler-reference.html#script, add a reference to the “Create standalone Kotlin scripts” page with a text like “For more info, see […]” @ilya.chernikov could you let me know if it roughly makes sense?
👍 2
i
I'm not sure that the standalone script is a more common case, I don't have any statistics at hands, but from the discussions here I have an impression that the embedded host scenario is used quite often too. Moreover, the tutorial part, related to the script definition jar is basically all you need to use the script in the standalone mode. But I agree that the standalone scenario is not properly documented, and there are maybe not enough depth in the description of
DependsOn
and other advanced stuff. There is definitely room to improve. Thank you for your feedback. I'll try to find out how better to process it. Unfortunately currently we do not have much free resources to write a new tutorial, but maybe we can figure out how to improve it with some minor update.
🙌 1
p
@ilya.chernikov thanks! do you mind if I post a short poll-like message here on #scripting, asking which use case is more important/common for a given person? with answers like: • definitely standalone scripts • mostly standalone scripts, some embedded host • roughly equally • mostly embedded host, some standalone scripts • definitely embedded host (not to force any solution regarding the docs, just out of curiosity and to give you more data)
i
Yes, of course, please do. I'm not sure that you'll get good representative data though. We made a large scripting survey some time ago, and we pushed it to many channels, and got barely enough responses to consider it representative. But the additional poll doesn't hurt for sure. I'd suggest to make it simpler though. I think it will bring us more data. E.g. • built-in .main.kts scripts • custom standalone scripts • custom embedded host
👍 1
p
what do you mean by built-in .main.kts scripts?
ah, I get it now - main.kts is a built-in script host
👌 1
👍 1
a
Hi there! Thanks for raising the issue, I really appreciate it. Unfortunately, we don’t have enough resources to cover the scripting docs completely. I created an issue in the YouTrack with the link to this thread. I hope we’ll come back to it in the foreseeing future.
👍🏾 1
👍 1
plus1 2