Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could work around the JVM start-up time by opening the Scala REPL and then loading your scripts directly into it using the <code>:load</code> command. This compiles (it does take some time, but I don't find it long in practice) the contents of the script and loads it for use in the REPL. For example:</p> <pre><code> scala> :load testScript.scala Loading testScript.scala... import scala.collection.mutable.Map memory: scala.collection.mutable.Map[Int,Int] = Map() fib: (Int)Int res7: Int = 165580141 scala> fib(10) res1: Int = 55 scala> fib(11) res2: Int = 89 scala> fib(12) res3: Int = 144 scala> fib(13) res4: Int = 233 </code></pre> <p>For example, a typical workflow of mine when writing different prototypes in Scala is as follows. I have a text editor open in one window, and the Scala REPL in another. I write my code and then load it (<code>:load script.scala</code>). The results produced by the script are immediately available (as seen in the above transcript, <code>res7</code>) and any functions, classes or objects defined in the script are also available. And it's faster than running <code>scala myScript.scala</code> as the JVM is already loaded.</p> <p>If you go the compiled route, use <code>fsc</code> (the fast Scala compiler). The first time it's invoked it creates a daemon process that compiles the code. Therefore you will only have to pay the JVM start-up price once. Just note that if you change the value of <code>CLASSPATH</code> (the environment variable), you'll have to restart <code>fsc</code> (it's something that has bugged me for a while).</p> <p><code>-- Flaviu Cipcigan</code></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload