LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

scala

Scala programming language interpreter and REPL

TLDR

Start REPL
$ scala
copy
Run script
$ scala [script.scala]
copy
Run with classpath
$ scala -cp [lib.jar] [script.scala]
copy
Evaluate expression
$ scala -e "println(1 + 2)"
copy
Run compiled class
$ scala [ClassName]
copy
With specific JVM memory
$ scala -J-Xmx[2g] [script.scala]
copy
Run in explain mode
$ scala -explain [script.scala]
copy

SYNOPSIS

scala [-cp classpath] [-e expr] [options] [script] [args]

DESCRIPTION

scala runs Scala programs and provides an interactive REPL. Scala combines object-oriented and functional programming on the JVM.The REPL evaluates expressions and shows results with types. Tab completion helps explore APIs. :help shows REPL commands.Scripts run directly without compilation. The Scala 3 runner can execute .scala files as scripts with dependencies.Classpath specifies libraries and compiled classes. Maven coordinates can specify dependencies in Scala 3.Compiler explanations help understand complex error messages. The explain mode provides detailed reasoning.The language supports type inference, pattern matching, implicits, and higher-order functions. It interoperates with Java seamlessly.

PARAMETERS

-cp, -classpath PATH

Set classpath for class files and libraries.
-e EXPR
Evaluate expression and print the result.
-J FLAG
Pass flag to JVM (e.g., -J-Xmx2g).
-deprecation
Show deprecation warnings.
-explain
Explain errors in detail with additional context.
-feature
Show feature warnings for advanced language features.
-help
Show help.
-version
Show version.
-X
Show advanced compiler options.
-Y
Show private compiler options.

CAVEATS

Scala 3 differs significantly from Scala 2. JVM startup adds latency. Memory usage can be high. Some features have learning curve.

HISTORY

Scala was designed by Martin Odersky at EPFL in Switzerland, with version 1.0 released in 2004. Scala 3 (Dotty), released in 2021, brought significant language improvements.

SEE ALSO

scalac(1), sbt(1), java(1), kotlin(1)

Copied to clipboard
Kai