I'm brand new to Kotlin and have just discovered that Kotlin can be used for scripts as well as in regular programs. Can anyone point me to a good tutorial on the scripting aspects of Kotlin?
I've certainly had a need to write scripts from time to time and have done so in languages like BASIC, REXX, and other more recent languages. If Kotlin can do similar things, I should probably spend a bit of time getting at least an overview on scripting in Kotlin.
But where can I run it? Or to put it another way, if I write a Kotlin script in, say, IDEA, that I want to run on my phone or another laptop, what has to be installed on that phone or laptop for the script to run correctly?
posted 7 months ago
Why would you want to run a Kotlin script on your phone? Unless you have some mobile Linux distribution, I think you'll have to write an entire Android/iPhone app.
I'm not following you. Do you mean I have to install IDEA on any device that needs to run a Kotlin script? Or that I don't need to install ANYTHING on the other device and the script will run just fine on the target machine from the development machine? The former seems to require a biggish IDE to be installed but that latter seems more like magic than anything. I was expecting to install some kind of (hopefully small) runtime environment on whatever machine runs the script.
posted 6 months ago
I didn't really have a specific use case in mind when I asked the question. It just struck me that if a script is useful on one device, I might want to use it on another and that device could be a laptop, a tablet or a phone. Or maybe a bunch of devices, as in the case of, say, a regular download of files. Or let's say I had sales databases on a variety of phones where each person recorded their own sales and a script ran daily to upload the days sales from each salesperson to a central database where everyone could see it and reports spanning the whole sales force could be run.
posted 6 months ago
Sounds like you just want to generally share code between platforms, and Kotlin has the exact same goal Take a look at Kotlin Multiplatform projects, these allow you to have so-called common code that can be reused across platforms.
Kotlin Scripts are a special type of Kotlin file that are useful to test code snippets, share pieces of code, or do smaller tasks as with batch scripts. No need to use scripts for what you're trying to do.