Need to write a new script. Deciding between doing...
# scripting
c
Need to write a new script. Deciding between doing it in bash, using kotlin to make a jar to execute, but I know "kotlin scripts" exists. What's the different between a kotlin script and just building a jar?
m
Scripts are self contained. You can add dependencies from the script itself without having to use gradle/maven/manually invoking the compiler
More generally, it's less things to write and worry about as they are compiled on-demand and cached
c
Interesting. I guess I need to take a look at some examples as it's still not immediately clear. Most of my scripts execute some curl commands and get some user input, but error handling user input in bash and curl commands failing has been a little painful hence why I am just thinking about writing a full on cmd line application.
Oh hey, did a search for kotlin scripting examples and your article is second from the top. nice SEO Martin 😄
🙂 2
Article was very helpful. https://mbonnin.medium.com/may-2020-the-state-of-kotlin-scripting-99cb6cc57db1 Looks like the biggest difference between a kotlin cmd line app that and a kotlin script is that with a cmd line app you still have to compile it and distribute/run it that way, vs a kotlin script is basically just a source code file and you can execute it directly. Would love to see an update of that article for 2021!
m
Ahah yes ! This article worked well 😊! TBH, I don't think much has changed in one year. Mainly improvements around dependencies resolution and other bug fixes but the big thing was being able to use '*.main.kts' without kscript
"Looks like the biggest difference between a kotlin cmd line app that and a kotlin script is that with a cmd line app you still have to compile it and distribute/run it that way, vs a kotlin script is basically just a source code file and you can execute it directly."
Yep, +1. I love it though. Being able to ship just a single file is nice.