Ki is a New, More Flexible Kotlin Interactive Shell – InfoQ.com

Ki is a new interactive shell for Kotlin that aims to make it easier for developers to do quick experiments with the language and to take advantage of REPL-driven development.

Ki is not the only interactive shell to be available for Kotlin. Rather, it tries to overcome the limitations of existing Kotlin interactive shells, as JetBrains engineer Pasha Finkelshteyn explains:

kotlinc does not have autocomplete or syntax highlighting. Kotlin REPL is very powerful, but it forces you to open IntelliJ IDEA, which is not always convenient.

Ki supports autocompletion, aimed to simplify access to Kotlin collection API; external dependencies, thanks to a special :dependsOn construct that loads a dependency from Maven Central and makes it available locally; and type inference, with the added bonus of a built-in t command which is able to show the type of any given expression.

Additionally, ki provides a special paste mode to better handle large code snippets. This mode can be enabled by executing the command :paste, which makes the REPL able to swallow whole chunks of code that are immediately interpreted and can be referenced later.

Another interesting features of ki is scripting support, which enables saving a session to disk and load it back using the :l command. After loading a script, the :ls command will show you a list of all imported symbols, including functions, classes, variables, etc. This is especially useful to spare oneself the chore of loading all required dependencies each time, says Finkelshteyn.

@file:DependsOn("com.GitHub.kittinunf.fuel:fuel:2.3.1")
import com.GitHub.kittinunf.fuel.*
import java.net.* fun sendGet(address:
Source...