I've developed a little script (see attachment) to turn Kotlin into a scripting language. e.g.
EDIT: This script has now moved to https://github.com/andrewoma/kotlin-script removing the previous limitations. It’s been tested under OS X and Linux (and cygwin with a patched kolinc).
#!/usr/bin/env kotlin println(“Hello from Kotlin!”) for (arg in args) { println(“arg: $arg”) }
Features:
Supports scripts where the first line is #! and wraps them in a main method
Supports standalone scripts with a main function
Caches compiled versions of scripts. (“Hello, world” seems to take around 3s to run with compilation and 200ms thereafter)
Limitations:
Currently OS X only (although it could easily be ported to any unix/cygwin)
Doesn’t support things like kotlinc being a symlink, honouring JAVA_HOME etc
I guess the ultimate location for something like this would be along-side kotlinc in the distribution.
Or would you prefer me to put it in my own github repo until it matures?
I’ve rewritten the script to remove the previous limitations and make it cross-platform (including removing the dependency on md5). I’ve tested it on OS X, Linux and cygwin.
Under the “Compiler and Plugin” section there’s an “Artifacts” dropdown menu. You can download the kotlin zip file from there (it’s probably best sticking to a version that has been verifed). Within that .zip file there’s the kotlinc scripts (in the bin directory).