Scala Programming Language – An Overview
The
Scala programming language belongs to a class of programming languages
known as ‘Functional Programming Languages’. Before we proceed further,
let us have a quick re-cap of some the core concepts of functional
programming languages, which we covered in an earlier blog post titled
‘Functional Programming – An Introduction’.
In
Mathematics, ‘functions’ express the connection between parameters
(inputs, in the case of computers) and the result (the output, in the
case of computers) of certain processes. In each computation, the result
depends on the parameters in a particular way and hence a ‘function’ is
a good way of specifying a computation. This is the basis of
‘Functional Programming’.
The above notion is also more close to the ‘human
world’ than to the world of a computer where in the initial days of
computing, programs consisted of instructions to modify the memory,
executed by the central processing unit. Thus, functional programming
languages match the mathematical idea of functions.
A function is
fundamentally a transformation. It transforms one or more inputs into
exactly one output.
An important property of functions is that they
yield no side effects – this means that the same inputs will always
yield the same outputs, and that the inputs will not be changed as a
result of the function. Every symbol in functional programming language
is immutable.
Functional programming treats computations –
running a program, solving a numeric calculation – as the evaluation of
functions.
Having covered the key concepts of functional
programming, let us move on to the industry scenario that led to the
evolution of Scala programming language. Moore’s Law states that CPU
speeds will double every 18 months. However, these days the focus is to
create CPUs with multiple cores – meaning multiple CPUs within a single
chip. This means that the multithreaded environment is executing on more
than one CPU simultaneously as opposed to the standard ‘round-robin’
cycle executing on a single CPU. Multithreading on multiple CPUs
requires that the code must be highly thread-safe.
Attempts to resolve this problem of having highly
thread-safe code has resulted in many new programming languages that
addresses the concurrency problem, each language with its own virtual
machine or interpreter. This obviously means that a transition to a new
platform is required, similar to what happened when organizations moved
from C++ to Java, about a decade ago. Such a transition is a non-trivial
task and most companies consider another transition risk prone. This
sets the stage for the arrival of Scala programming language.
Scala is a
statically typed, object-oriented programming language. In addition to
being object oriented, Scala is also a functional programming language
and blends the best approaches to object-oriented programming and
functional programming. Scala is designed and developed to run on the
Java Virtual Machine (JVM) and Scala’s operational characteristics are
same as Java’s. In fact, the Scala compiler generates byte codes that
are nearly similar to that generated by Java compiler. This
compatibility ensures that Scala language can utilize existing Java
code, which in turn means that Scala has access to the existing
ecosystem of Java code, including open-source code.
In Italian
language, ‘Scala’ means stairway or steps. The name ‘Scala’ was selected
to imply that Scala programming language allows programmers to
‘step-up’ to a programming environment that incorporates the latest in
programming language design and at the same time letting programmers use
all existing Java code. Scala also means ‘scalable language’, which
means the language is designed to grow with the demands of its users.
Scala has been
generating significant interest in the software industry and companies
are announcing their move to Scala. Twitter,
in April 2009, announced that they have switched a large portion of
their backend to Scala and intend to convert the rest. Wattzon has mentioned that their
entire platform has been written from the ground up in Scala.
Professor Martin Odersky
is the creator of the Scala language. As a professor at EPFL in Lausanne,
Switzerland, he is
working on programming languages, more specifically languages for
object-oriented and functional programming. His research thesis is that
the two paradigms are two sides of the same coin, to be identified as
much as possible. To prove this, he has experimented with a number of
language designs, from Pizza to GJ to Functional Nets. He has also
influenced the development of Java as a co-designer of Java generics and
as the original author of the current javac reference compiler. Since
2001, Prof. Odersky has concentrated on designing, implementing, and
refining the Scala programming language.
Before we conclude this
discussion, I would like to quote a reference to Scala from a previous
blog post, titled ‘Technology Choices for 2009 and Beyond...’ posted on
24 September 2008.
“Another
relatively new [first public release in 2003] language, Scala, designed
and built by the team led by Prof. Martin Odersky (EPFL, Switzerland)
[Prof. Odersky has also influenced the development of Java as a
co-designer of Java generics and as the original author of the current
javac reference compiler] also seems to be promising. On a related note,
in the article titled "Java EE meets Web 2.0" written by Constantine
Plotnikov, Artem Papkov and Jim Smith in developerWorks, November 2007),
the authors identifies principles of the Java EE platform that are
incompatible with Web 2.0 and introduces technologies, including Scala,
that close the gap.”
This concludes our discussion on Scala programming
language, which is expected to transform software engineering, the way
Java programming language did about a decade ago.