Scala (language)

Scala is a multi-paradigm programming language designed at the Swiss Federal Institute of Technology in Lausanne (EPFL) to express common programming patterns in a concise and elegant form. Its name comes from the English Scalable language which means roughly “adaptable language” or “language that can be scaled”. It can indeed be seen as a metalanguage .

Scala integrates object-oriented programming and functional programming paradigms , with static typing . It thus reconciles these two usually opposing paradigms (with rare exceptions, such as the OCaml language ) and gives the developer the opportunity to choose the paradigm most appropriate to his problem.

It is intended to be compiled in Java bytecode (executable on the JVM ), or .Net . Only the Java platform is officially supported by EPFL.

If you want to use it exclusively with the JVM, you can use libraries written in Java in a completely transparent way. Thus, Scala benefits from the maturity and the diversity of the libraries which have been the force of Java for a decade. Moreover, it is possible to invoke code written in Scala from programs written in Java which facilitates the transition from Java to Scala.

Developers accustomed to a single paradigm (for example, those who have used mainly Java, which relies on object-oriented programming) can find this language confusing and difficult because it requires learning different concepts if one is to exploit all its potential . Nevertheless, it is quite possible to use it initially as a replacement for Java, taking advantage of its purified syntax, then to use the different “new” concepts as they are learned.

Example Hello World

The Hello world program written in Scala, in the Java way :

object HelloWorld {
 def main ( args : Array [ String ]) {
 System.out.println ( "Hello, world!" )

Or simply without declaration of class and static method, with a simple singleton object:

Object HelloWorld extends App {
 println ( "Hello, world!" )

One of these two examples can be saved in a file HelloWorld.scalaand compiled on the command line:

$ scalac HelloWorld.scala

Then executed:

$ scala -classpath . HelloWorld

Using Scala as a script language :

Println ( "Hello, world!" )

And saved in a file HelloWorld2.scala, then executed directly on the command line:

$ scala HelloWorld2.scala

The source code can also be supplied directly to the interpreter with the -e option :

$ scala -e 'println("Hello, World!")'


IDE integration, text editor

  • Plugin for Eclipse  [ archive ]
  • Plugin for Intellij IDEA  [ archive ]
  • Plugin for ATOM  [ archive ]
  • Vim Scala  [ archive ]
  • Emacs Scala  [ archive ]
  • Scala Build tool  [ archive ]
  • Scala Maven Plugin  [ archive ]

Tests Frameworks

  • ScalaTest  [ archive ]
  • Specs2  [ archive ]
  • ScalaCheck  [ archive ]
  • ScalaMock  [ archive ]

Notes and references

  1. ↑ Martin Odersky et al., An Overview of the Scala Programming Language, 2nd Edition .