Scala Overview
Jakob Jenkov |
This text is an attempt to provide you with an overview of the Scala programming language and Scala platform. Since Scala is being developed all the time, this overview page may change over time. Additionally, as I learn more about the Scala language, I may add to this text too.
Scala runs on the Java Virtual Machine
Scala is compiled into Java Byte Code which is executed by the Java Virtual Machine (JVM). This means that Scala and Java have a common runtime platform. If you or your organization has standardized on Java, Scala is not going to be a total stranger in your architecture. It's a different language, but the same runtime.
Scala can Execute Java Code
Since Scala is compiled into Java Byte Bode, it was a no-brainer for the Scala language designer (Martin Odersky) to enable Scala to be able to call Java code from a Scala program. You can thus use all the classes of the Java SDK's in Scala, and also your own, custom Java classes, or your favourite Java open source projects.
Scala Has a Compiler, Interpreter and Runtime
Scala has both a compiler and an interpreter which can execute Scala code.
The Scala compiler compiles your Scala code into Java Byte Code which can then be
executed by the scala
command. The scala
command is similar
to the java
command, in that it executes your compiled Scala code.
Since the Scala compiler can be a bit slow to startup, Scala has a compiler daemon you can run. This daemon keeps running, even when not compiling Scala code. You can then instruct the daemon to compile Scala code for you at will. This saves you the Scala compiler startup overhead when compiling.
The Scala interpreter runs your Scala code directly as it is, without you needing to compile it. The Scala interpreter may come in handy as a Scala script interpreter, a bit like a shell script interpreter on a Unix platform.
Scala Features
Scala has a set of features which differ from Java. Some of these are:
- All types are objects.
- Type inference.
- Functions are objects.
- Domain specific language (DSL) support.
- Traits.
- Closures.
- Concurrency support inspired by Erlang.
Scala for the Web
One of the popular Scala web frameworks is called Lift. You can find it here:
Tweet | |
Jakob Jenkov |