Scala, higher level of language in Java virtual machine
Created by the LAMP group at the Federal Polytechnic School of Lozan (EPFL) under the guidance of Professor Martin Odersky, The Rock is a universal programming language designed to provide short and simple code. It is close to Java with borrowings from various other languages, but also brings innovations and simplifications, which makes you think about JavaScript. This results in slow compilation.
It is based on domain-oriented programming no less than functional languages. According to the authors, Scala code is two to three times more concise than equivalent code in Java. But you can also write such unreadable code as Perl's. Like Perl, it allows you to do the same in very different ways.
The code can be compiled in Java or .NET bytecode and is compatible with their respective runtimes. In February 2015, the Scala.js compiler in JavaScript was declared suitable for use in production.
The word scala is short for SCAlable LAnguage and also means ladder in Italian, symbolizing multi-level programming.
The scalac compiler is BSD licensed. Since 2014, leading compiler developers have been working on a new language - Dotty, a simplified version of Scala, which should remove intractable problems to improve this compiler.

March 14, 2017 Scala Native is announced. (Article in English). We are talking about replacing the Java virtual machine with LLVM and, therefore, creating executable binaries. A full library is attached to this, but Java is still required to run.
In May 2021, Scala 3 arrives, offering simplicity in syntax. You can write code with indentation, as Python does instead of hugging. Now it is optional, but you can always use the classic syntax.
Characteristics of the Rock
You should be aware that many elements of the language, such as return or for, for example, do not work as is customary in previous languages .
Syntax and constructs:
- Functionality: functions are values .
- Object-oriented-All values are objects.
- Statically typed.
- Declarations are flipped relative to C: a variable is named and then its type is determined .
- The function is defined by the def operator, and the header is similar to Pascal .
- There is no such terminator as; at the end of instructions (but it can be added additionally ).
- A class with a header constructor is defined, which is more concise. See examples.
- Traits are interfaces, as in Java, but whose methods can be defined or not. When you use a line to complete a class, you must identify methods that do not exist. So their action depends on the context of use.
- Actors are objects that work in a competitive environment (synchronous or asynchronous) and communicate by message. The actor is determined by the list of messages that he can receive. He can react to one message by sending another, so an exchange system can be created.
- No break and continuation.
- The type val is equivalent to a constant, but it can be initialized with a variable.
- Many collection structures: List, Vector, Set, Map, Seq, Pair, Triple .
- You can include XML in the source as Script does.
- Scala 3 offers a simulated Python syntax.
Other possibilities:
- Anonymous features.
- First-order functions.
- A function can contain functions.
- General classes. In accordance with
- one condition establishes a class field for the matching pattern, that is, to select a class from a list.
- Polymorphic methods. Arguments can change type.
- Extensible: as operator you can use the method.
- Abstractions.
- Nested functions.
- Regular expressions defined by procedural code. and
- many other original characteristics...
Example code in Scala, show "Hello world!":
object HelloWorld { def main(args: Array[String]) { println("Salut le Monde!") } }
Define class:
class voiture(vitesse:Integer, nom:String) { ... corps du constructeur et de la classe ... }
Why use the Rock
?Scala contributes to the gradual evolution of programs over time.
Scala code can easily interact with pre-existing Java code. It is actually compiled in Java bytecode. Thus, both languages can be used in the same program, since Scala provides, in particular, the advantage of greater brevity.
Scala makes XML documents easy to process.
Social site Twitter ditched the Ruby language for the backend and programmed its services on Scala to take advantage of the evolutionary nature of the language. The site gradually builds an audience and offers new services over time, hence the need for language to facilitate the expansion of programs without rewriting them .
Tools and documents
- La Scala
Language site. Loading compiler and reference guide. - Getting started
How to make and run a simple program. - Scastia
Online console for testing Scala code. - Scaladex
Directory of language libraries . - Scala.js
Compiles Scala into JavaScript 5.1. It is possible to use JS libraries from Scala, but this requires conversion of types and formats that make it complex. - Twitter and the Rock
Interview of social site programmers who implemented Scala. With - Using the Scala For Android project, you can run Android applications using Scala.