You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.adoc
+11-31Lines changed: 11 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,9 +24,7 @@ In particular this wrapper around `kotlinc` adds
24
24
Taken all these features together, `kscript` provides an easy-to-use, very flexible, and almost zero-overhead solution
25
25
to write self-contained mini-applications with Kotlin.
26
26
27
-
*Good News*: Kotlin https://kotlinlang.org/docs/reference/whatsnew14.html#scripting-and-repl[v1.4] finally ships with a much improved - and needed - scripting integration. See https://github.com/Kotlin/kotlin-script-examples/blob/master/jvm/main-kts/MainKts.md[here] for examples and documentation. Still, we think that `kscript` has various benefits compared this new platform-bundled improved toolstack, so we'll plan to support `kscript` until the kotlin platform will ship with an even more rich and versatile kotlin scripting interpreter.
28
-
29
-
*https://holgerbrandl.github.io/kscript_kotlinconf_2017/kscript_kotlinconf.html[`kscript` presentation from KotlinConf2017!]*
27
+
Kotlin's native scripting capabilities have continually improved, providing a solid foundation. `kscript` builds upon this by offering a rich set of features to enhance the scripting experience, including simplified dependency management, compiled script caching, flexible script input modes, and deployment options. While Kotlin's own scripting support is powerful, `kscript` aims to provide additional conveniences and power tools for scripters.
30
28
31
29
'''
32
30
* <<Installation>>
@@ -64,6 +62,8 @@ Once Kotlin is ready, you can install `kscript` with
64
62
sdk install kscript
65
63
----
66
64
65
+
Package managers like SDKMAN, Homebrew, and Scoop provide convenient ways to install `kscript`. Note that the version they provide might not always be the absolute latest. For the most recent updates or to use `kscript` with very new Kotlin/Java versions, consider the <<Build it yourself>> section.
66
+
67
67
To test your installation simply run
68
68
69
69
[source,bash]
@@ -169,8 +169,11 @@ To install `scoop` use the https://github.com/ScoopInstaller/Install[official gu
169
169
170
170
=== Build it yourself
171
171
172
-
To build `kscript` yourself, simply clone the repo and do
172
+
To build `kscript` yourself, which can be useful for accessing the very latest features or using it with specific modern Kotlin/Java versions (like Kotlin 2.2.0+ and Java 21+ which have been tested):
173
+
174
+
Ensure you have a modern JDK installed (e.g., JDK 17 or newer, JDK 21 recommended for recent Kotlin versions). The build uses the Gradle wrapper (`gradlew`), which will download the appropriate Gradle version.
173
175
176
+
Clone the repository and then run:
174
177
[source,bash]
175
178
----
176
179
./gradlew assemble
@@ -445,9 +448,9 @@ dependencies:
445
448
----
446
449
io.github.kscripting:kscript-annotations:1.5
447
450
----
451
+
// (Note: The `kscript-annotations` artifact version `1.5` is from an older release cycle. While it may still work for basic annotations, for projects using newer Kotlin versions (like 2.x), you might need to check for a more recent version of `kscript-annotations` if available, or be mindful of potential Kotlin standard library version misalignments if this artifact pulls in an older one.)
448
452
449
-
`kscript` will automatically detect an annotation-driven script, and if so will declare a dependency on this artifact
450
-
internally.
453
+
`kscript` will automatically detect an annotation-driven script, and if so will declare a dependency on `io.github.kscripting:kscript-annotations` (historically version 1.5) internally.
451
454
452
455
Note, that if a script is located in a package other than the root package, you need to import the annotations with (
453
456
e.g. `import DependsOn`).
@@ -729,21 +732,7 @@ the `@file:Entry`.
729
732
730
733
=== What are performance and resource usage difference between scripting with kotlin and python?
731
734
732
-
Kotlin is a compiled language, so there is a compilation overhead when you run a script/application written in Kotlin
733
-
for the first time.
734
-
735
-
Kotlin runs (mainly) on the JVM which needs some time (~200ms) to start up. In contrast, the python interpreter has
736
-
close to zero warmup time.
737
-
738
-
I think there is a consensus that JVM programs execute much faster than python equivalents. Still, python might be
739
-
faster depending on your specific usecase. Also, with kotlin-native becoming more mature, you could compile into native
740
-
binaries directly, which should bring it close to C/C++ performance.
741
-
742
-
Main motivations for using Kotlin over Python for scripting and development are
743
-
744
-
* Kotlin is the better designed, more fluent language with much better tooling around it
745
-
* The JVM dependency ecosystem allows for strict versioning. No more messing around with virtualenv, e.g. to run a short
746
-
10liner against a specific version of numpy.
735
+
Kotlin scripts involve a JVM startup and, for the first run of a script, a compilation step. While the JVM offers excellent peak performance for longer-running or complex tasks, the initial overhead might be noticeable for very short-lived, simple scripts when compared to languages like Python that have minimal startup time. The best choice often depends on the specific use case, script complexity, access to Java/Kotlin libraries, and developer familiarity with the ecosystems.
747
736
748
737
=== Does kscript work with java?
749
738
@@ -774,16 +763,7 @@ Help to spread the word. Great community articles about `kscript` include
774
763
-using kscript
775
764
776
765
You could also show your support by upvoting `kscript` here on github, or by voting for issues in Intellij IDEA which
777
-
impact `kscript`ing. Here are our top 2 tickets/annoyances that we would love to see fixed:
778
-
779
-
* https://youtrack.jetbrains.com/issue/KT-13347[KT-13347] Good code is red in injected kotlin language snippets
780
-
781
-
To allow for more interactive script development, you could also vote/comment on the most annoying REPL issues.
782
-
783
-
* https://youtrack.jetbrains.net/issue/KT-24789[KT-24789] "Unresolved reference" when running a script which is a
784
-
symlink to a script outside of source roots
785
-
* https://youtrack.jetbrains.com/issue/KT-12583[KT-12583] IDE REPL should run in project root directory
786
-
* https://youtrack.jetbrains.com/issue/KT-11409[KT-11409] Allow to "Send Selection To Kotlin Console"
766
+
impact `kscript`ing. For specific kscript issues or feature proposals, please use the kscript GitHub issue tracker. For broader Kotlin language or IDE-related issues, the official JetBrains YouTrack is the appropriate place.
0 commit comments