Open dominique-unruh opened 3 weeks ago
if you don't intend to change it that often you can package it to an executable
scala package -o test_sc test.sc
then it will be as fast as you wanted - just with an extra file
I guess this isn't acceptable given the alternative listed
one has to manually ensure that the compilation is up to date
perhaps it is possible to run scala-cli's caching checks quicker than 0.6 seconds? hinting at a missed opportunity for specifically native script files
perhaps it is possible to run scala-cli's caching checks quicker than 0.6 seconds? hinting at a missed opportunity for specifically native script files
I think that there could also be similar room for improvement with Scala.js – or larger, in fact, because it seems that whenever I run a Scala.js script, it tries to fetch something. 🤔
$ ./scala-js
https://github.com/virtusLab/scala-js-cli/releases/download/v1.16.0.1/scala-js-ld-aarch64-apple-darwin.gz
0.0% [ ] 0B (0B / s)
$ cat scala-js
#!/usr/bin/env -S scala-cli shebang
//> using scala 3.5.0
//> using platform scala-js
//> using jsVersion 1.16.0
println("Hello")
$ scala-cli version
Scala CLI version: 1.5.0
Scala version (default): 3.5.0
By the way, here's a small benchmark I did out of curiosity:
Is your feature request related to a problem? Please describe.
When running a scala script with native compilation, there is a noticeable delay.
Example:
test.sc
isI run:
time ./test.sc
(compilation happens) and againtime ./test.sc
. I get:The startup time is 0.6s (which (on my computer) actually a tiny bit slower than with JVM compilation).
The documentation seems to indicate that it is possible to get instant startup using native (https://scala-cli.virtuslab.org/docs/cookbooks/introduction/instant-startup-scala-scripts/).
Describe the solution you'd like
This script to finish in a non-noticeable amount of time, not 0.6s. For comparison, on the same machine, a comparable Python script runs 0.03s.
This would allow to write scripts that can be used interactively in the shell, with reactivity comparable to shell scripts or Python scripts.
Describe alternatives you've considered
.scala-build
). This means that one has to manually ensure that the compilation is up to date, and also find the file. Not suitable for scripting.Additional context
3127 raised the same problem but was closed because (as far as I understood) it raised several issues in one.