Scala, a scalable language on the Java virtual machine
Created by the LAMP group at the Ecole Polytechnique Fédérale de Lausane (EPFL), led by Professor Martin Odersky, Scala is a universal programming language designed to allow a simple and concise code. It is close to Java with features from various other languages.
It is inspired by object-oriented programming languages as well as functional. According to the authors, the Scala code is two to three times more concise than the equivalent code in Java.
The scala word is short for SCAlable LAnguage and means stairs in Italian, which symbolizes programming by steps.
The compiler is licensed under BSD.
Features of Scala
- Object-Oriented: all values are objects.
- Functional: Functions are values.
- Syntax similar to Java. Compiled into Java bytecode.
- Anonymous functions.
- First-order fFunctions.
- Statically typed.
- Generic Classes.
- Polymorphic methods.
- Programming abstractions.
- Extensible: A method can be used as an operator.
- Nested functions.
- No terminator at end of instructions such as ";" in Java.
- No break and continue.
- A function is defined by the def operator and the header is near that of Pascal.
- Regular expressions defined by procedural code.
- Compatible with the Java runtime.
- Compatible with the . NET runtime.
Sample code, displaying "Hello World":
object HelloWorld {
def main(args: Array[String]) {
println("Salut le Monde!")
}
}
Why use Scala?
Scala facilitates the gradual evolution of the programs over time.
Scala code can easily interface with existing Java code. It is compiled into Java bytecode. We can use both languages in a single program, Scala providing the advantages of being more concise.
Scala allows you to easily process XML documents.
The social site Twitter has left the Ruby language for backend and implemented its services in Scala, that to take advantage of the scalable nature of the language. The site is gradually increasing its audience and offer new services over time, hence the need for a language that facilitates the expansion of programs without rewriting.
Tools and documents
- Scala
Official site of the language. Download the compiler and reference manual. - Getting started
How to build and and run a simple program. - Twitter and Scala
Interview of programmers of the social site that implemented Scala. - Scala For Android allows to build application for smartphones.
