Learn Java for Web Development

(Tina Meador) #1
423

Appendix C


Introduction to Scala


Scala seamlessly integrates object-oriented and functional programming. Scala is a statically typed
language that was conceived in 2001 by Martin Odersky, who also wrote the Java reference compiler
and coauthored Java generics. Scala compiles to byte code for the Java Virtual Machine (JVM),
making it platform independent. That also means that from a Scala program you can use existing
Java libraries, and vice versa.


Getting Started with Scala


You can download Scala from http://www.scala-lang.org/download/. This Scala software distribution can
be installed on any Unix-like or Windows system. It requires the Java runtime version 1.6 or newer.



scala -version



Scala code runner version 2.10.3 -- Copyright 2002-2013, LAMP/EPFL


There are three ways to execute Scala code.


   Using the interactive interpreter
 Executing Scala code as a script
 Compiling Scala code

Using the Interactive Interpreter

The Scala interpreter (called a read-evaluate-print loop, or REPL) is the easiest way to execute a
single line of Scala code. You can start the interactive interpreter using the Scala command-line tool
scala, which is located in the bin folder in the folder where Scala is installed.

Free download pdf