I'd like to get short Scala scripts running as fast as python scripts do, particularly in terms of script startup time.
Can anyone recommend some ways of doing this, that doesn't involve compiling with GCJ, for instance?
One way I can think of is to run the script using the JVM's client mode, but I can't seem to get this working. An example (known-good) shebang for this would be great.
UPDATE: I'm aware of the other questions, but don't think any workable answers have been found so far, as I'm looking for solutions that work on STANDARD installs, without additional requirements. This is what I was trying to get at with "doesn't involve compiling with GCJ, for instance".
It seems that -client mode is designed for this express purpose, but it's just awkward to activate from scala scripts for some reason.
As many other questions have gone before, if one could only know how to look for them, use Nailgun.
Other ways to improve on script performance is to start fsc
at system boot, so it will be available for scripts, and use -savecompiled
, to avoid repeated compilation of scripts.
EDIT
You mention -client
mode, but I think that's really not a good choice. The will give you a slower Scala compiler, and do little to improve the startup time of the compiler itself, if not Java. Much better to have fsc
as daemon, running as -server
, and/or save compiled scripts with -savecompiled
.
Now, I don't know what problems you are having with -client
, but I have read that it doesn't work with 64 bits JVM. Might that be your case?
PS: Looking up similar questions, I noticed JRuby has builtin Nailgun support!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With