<s>
Scala	B-Application
(	O
)	O
is	O
a	O
strong	O
statically	O
typed	O
high-level	B-Language
general-purpose	B-Language
programming	I-Language
language	I-Language
that	O
supports	O
both	O
object-oriented	B-Language
programming	I-Language
and	O
functional	B-Language
programming	I-Language
.	O
</s>
<s>
Designed	O
to	O
be	O
concise	O
,	O
many	O
of	O
Scala	B-Application
's	O
design	O
decisions	O
are	O
aimed	O
to	O
address	O
criticisms	B-Language
of	I-Language
Java	I-Language
.	O
</s>
<s>
Scala	B-Application
source	O
code	O
can	O
be	O
compiled	B-Language
to	O
Java	B-Language
bytecode	I-Language
and	O
run	O
on	O
a	O
Java	B-Language
virtual	I-Language
machine	I-Language
(	O
JVM	B-Language
)	O
.	O
</s>
<s>
Scala	B-Application
can	O
also	O
be	O
compiled	B-Language
to	O
JavaScript	B-Language
to	O
run	O
in	O
a	O
browser	O
,	O
or	O
directly	O
to	O
a	O
native	O
executable	O
.	O
</s>
<s>
On	O
the	O
JVM	B-Language
Scala	B-Application
provides	O
language	B-Language
interoperability	I-Language
with	O
Java	B-Language
so	O
that	O
libraries	O
written	O
in	O
either	O
language	O
may	O
be	O
referenced	O
directly	O
in	O
Scala	B-Application
or	O
Java	B-Language
code	I-Language
.	O
</s>
<s>
Like	O
Java	B-Language
,	O
Scala	B-Application
is	O
object-oriented	B-Language
,	O
and	O
uses	O
a	O
syntax	O
termed	O
curly-brace	O
which	O
is	O
similar	O
to	O
the	O
language	O
C	B-Language
.	O
Since	O
Scala	B-Application
3	O
,	O
there	O
is	O
also	O
an	O
option	O
to	O
use	O
the	O
off-side	B-Language
rule	I-Language
(	O
indenting	O
)	O
to	O
structure	O
blocks	O
,	O
and	O
its	O
use	O
is	O
advised	O
.	O
</s>
<s>
Martin	O
Odersky	O
has	O
said	O
that	O
this	O
turned	O
out	O
to	O
be	O
the	O
most	O
productive	O
change	O
introduced	O
in	O
Scala	B-Application
3	O
.	O
</s>
<s>
Unlike	O
Java	B-Language
,	O
Scala	B-Application
has	O
many	O
features	O
of	O
functional	B-Language
programming	I-Language
languages	I-Language
(	O
like	O
Scheme	B-Language
,	O
Standard	B-Language
ML	I-Language
,	O
and	O
Haskell	B-Language
)	O
,	O
including	O
currying	B-Application
,	O
immutability	B-Application
,	O
lazy	O
evaluation	O
,	O
and	O
pattern	B-Language
matching	I-Language
.	O
</s>
<s>
It	O
also	O
has	O
an	O
advanced	O
type	O
system	O
supporting	O
algebraic	O
data	O
types	O
,	O
covariance	O
and	O
contravariance	O
,	O
higher-order	O
types	O
(	O
but	O
not	O
higher-rank	O
types	O
)	O
,	O
anonymous	B-Language
types	I-Language
,	O
operator	O
overloading	B-Application
,	O
optional	O
parameters	O
,	O
named	O
parameters	O
,	O
raw	O
strings	O
,	O
and	O
an	O
experimental	O
exception-only	O
version	O
of	O
algebraic	O
effects	O
that	O
can	O
be	O
seen	O
as	O
a	O
more	O
powerful	O
version	O
of	O
Java	B-Language
's	O
checked	O
exceptions	O
.	O
</s>
<s>
The	O
name	O
Scala	B-Application
is	O
a	O
portmanteau	O
of	O
scalable	O
and	O
language	O
,	O
signifying	O
that	O
it	O
is	O
designed	O
to	O
grow	O
with	O
the	O
demands	O
of	O
its	O
users	O
.	O
</s>
<s>
The	O
design	O
of	O
Scala	B-Application
started	O
in	O
2001	O
at	O
the	O
École	O
Polytechnique	O
Fédérale	O
de	O
Lausanne	O
(	O
EPFL	O
)	O
(	O
in	O
Lausanne	O
,	O
Switzerland	B-Protocol
)	O
by	O
Martin	O
Odersky	O
.	O
</s>
<s>
It	O
followed	O
on	O
from	O
work	O
on	O
Funnel	O
,	O
a	O
programming	O
language	O
combining	O
ideas	O
from	O
functional	B-Language
programming	I-Language
and	O
Petri	B-Operating_System
nets	I-Operating_System
.	O
</s>
<s>
Odersky	O
formerly	O
worked	O
on	O
Generic	B-Language
Java	I-Language
,	O
and	O
javac	B-General_Concept
,	O
Sun	O
's	O
Java	B-Language
compiler	B-Language
.	O
</s>
<s>
After	O
an	O
internal	O
release	O
in	O
late	O
2003	O
,	O
Scala	B-Application
was	O
released	O
publicly	O
in	O
early	O
2004	O
on	O
the	O
Java	B-Device
platform	I-Device
,	O
A	O
second	O
version	O
(	O
v2.0	O
)	O
followed	O
in	O
March	O
2006	O
.	O
</s>
<s>
On	O
17	O
January	O
2011	O
,	O
the	O
Scala	B-Application
team	O
won	O
a	O
five-year	O
research	O
grant	O
of	O
over	O
€2.3	O
million	O
from	O
the	O
European	O
Research	O
Council	O
.	O
</s>
<s>
On	O
12	O
May	O
2011	O
,	O
Odersky	O
and	O
collaborators	O
launched	O
Typesafe	O
Inc	O
.	O
(	O
later	O
renamed	O
Lightbend	O
Inc	O
.	O
)	O
,	O
a	O
company	O
to	O
provide	O
commercial	O
support	O
,	O
training	O
,	O
and	O
services	O
for	O
Scala	B-Application
.	O
</s>
<s>
Scala	B-Application
runs	O
on	O
the	O
Java	B-Device
platform	I-Device
(	O
Java	B-Language
virtual	I-Language
machine	I-Language
)	O
and	O
is	O
compatible	O
with	O
existing	O
Java	B-Language
programs	O
.	O
</s>
<s>
As	O
Android	B-Application
applications	I-Application
are	O
typically	O
written	O
in	O
Java	B-Language
and	O
translated	O
from	O
Java	B-Language
bytecode	I-Language
into	O
Dalvik	B-Application
bytecode	O
(	O
which	O
may	O
be	O
further	O
translated	O
to	O
native	O
machine	O
code	O
during	O
installation	O
)	O
when	O
packaged	O
,	O
Scala	B-Application
's	O
Java	B-Language
compatibility	O
makes	O
it	O
well-suited	O
to	O
Android	B-Application
development	O
,	O
more	O
so	O
when	O
a	O
functional	B-Language
approach	O
is	O
preferred	O
.	O
</s>
<s>
The	O
reference	O
Scala	B-Application
software	O
distribution	O
,	O
including	O
compiler	B-Language
and	O
libraries	O
,	O
is	O
released	O
under	O
the	O
Apache	B-Application
license	I-Application
.	O
</s>
<s>
is	O
a	O
Scala	B-Application
compiler	B-Language
that	O
compiles	B-Language
to	O
JavaScript	B-Language
,	O
making	O
it	O
possible	O
to	O
write	O
Scala	B-Application
programs	O
that	O
can	O
run	O
in	O
web	O
browsers	O
or	O
Node.js	B-Language
.	O
</s>
<s>
The	O
compiler	B-Language
,	O
in	O
development	O
since	O
2013	O
,	O
was	O
announced	O
as	O
no	O
longer	O
experimental	O
in	O
2015	O
(	O
v0.6	O
)	O
.	O
</s>
<s>
Scala	B-Application
Native	I-Application
is	O
a	O
Scala	B-Application
compiler	B-Language
that	O
targets	O
the	O
LLVM	B-Application
compiler	B-Language
infrastructure	O
to	O
create	O
executable	O
code	O
that	O
uses	O
a	O
lightweight	O
managed	O
runtime	O
,	O
which	O
uses	O
the	O
Boehm	B-Language
garbage	I-Language
collector	I-Language
.	O
</s>
<s>
Development	O
of	O
Scala	B-Application
Native	I-Application
began	O
in	O
2015	O
with	O
a	O
goal	O
of	O
being	O
faster	O
than	O
just-in-time	O
compilation	B-Language
for	O
the	O
JVM	B-Language
by	O
eliminating	O
the	O
initial	O
runtime	O
compilation	B-Language
of	O
code	O
and	O
also	O
providing	O
the	O
ability	O
to	O
call	O
native	O
routines	O
directly	O
.	O
</s>
<s>
A	O
reference	O
Scala	B-Application
compiler	B-Language
targeting	O
the	O
.NET	B-Application
Framework	I-Application
and	O
its	O
Common	O
Language	O
Runtime	O
was	O
released	O
in	O
June	O
2004	O
,	O
but	O
was	O
officially	O
dropped	O
in	O
2012	O
.	O
</s>
<s>
The	O
Hello	O
World	O
program	O
written	O
in	O
Scala	B-Application
3	O
has	O
this	O
form	O
:	O
</s>
<s>
Unlike	O
the	O
stand-alone	O
Hello	O
World	O
application	O
for	O
Java	B-Language
,	O
there	O
is	O
no	O
class	O
declaration	O
and	O
nothing	O
is	O
declared	O
to	O
be	O
static	O
;	O
a	O
singleton	O
object	O
created	O
with	O
the	O
object	O
keyword	O
is	O
used	O
instead	O
.	O
</s>
<s>
When	O
the	O
program	O
is	O
stored	O
in	O
file	O
HelloWorld.scala	O
,	O
the	O
user	O
compiles	B-Language
it	O
with	O
the	O
command	O
:	O
</s>
<s>
This	O
is	O
analogous	O
to	O
the	O
process	O
for	O
compiling	B-Language
and	O
running	O
Java	B-Language
code	I-Language
.	O
</s>
<s>
Indeed	O
,	O
Scala	B-Application
's	O
compiling	B-Language
and	O
executing	O
model	O
is	O
identical	O
to	O
that	O
of	O
Java	B-Language
,	O
making	O
it	O
compatible	O
with	O
Java	B-Language
build	O
tools	O
such	O
as	O
Apache	B-Application
Ant	I-Application
.	O
</s>
<s>
A	O
shorter	O
version	O
of	O
the	O
"	O
Hello	O
World	O
"	O
Scala	B-Application
program	O
is	O
:	O
</s>
<s>
Scala	B-Application
includes	O
an	O
interactive	O
shell	O
and	O
scripting	O
support	O
.	O
</s>
<s>
Saved	O
in	O
a	O
file	O
named	O
HelloWorld2.scala	O
,	O
this	O
can	O
be	O
run	O
as	O
a	O
script	O
using	O
the	O
command	O
:	O
</s>
<s>
Commands	O
can	O
also	O
be	O
entered	O
directly	O
into	O
the	O
Scala	B-Application
interpreter	O
,	O
using	O
the	O
option	O
:	O
</s>
<s>
Expressions	O
can	O
be	O
entered	O
interactively	O
in	O
the	O
REPL	B-Application
:	O
</s>
<s>
The	O
following	O
example	O
shows	O
the	O
differences	O
between	O
Java	B-Language
and	O
Scala	B-Application
syntax	O
.	O
</s>
<s>
//	O
Java	B-Language
:	O
</s>
<s>
Scala	B-Application
does	O
not	O
require	O
semicolons	O
(	O
;	O
)	O
to	O
end	O
statements	O
.	O
</s>
<s>
Parameter	O
and	O
return	O
types	O
follow	O
,	O
as	O
in	O
Pascal	B-Application
,	O
rather	O
than	O
precede	O
as	O
in	O
C	B-Language
.	O
</s>
<s>
Local	O
or	O
class	O
variables	O
must	O
be	O
preceded	O
by	O
val	O
(	O
indicates	O
an	O
immutable	B-Application
variable	O
)	O
or	O
var	O
(	O
indicates	O
a	O
mutable	B-Application
variable	I-Application
)	O
.	O
</s>
<s>
Instead	O
of	O
the	O
Java	B-Language
cast	O
operator	O
(	O
Type	O
)	O
foo	O
,	O
Scala	B-Application
uses	O
foo.asInstanceOf[Type],	O
or	O
a	O
specialized	O
function	O
such	O
as	O
toDouble	O
or	O
toInt	O
.	O
</s>
<s>
Instead	O
of	O
Java	B-Language
's	O
import	O
foo	O
.	O
</s>
<s>
*	O
;	O
,	O
Scala	B-Application
uses	O
import	O
foo._	O
.	O
</s>
<s>
Function	O
or	O
method	O
foo( )	O
can	O
also	O
be	O
called	O
as	O
just	O
foo	O
;	O
method	O
thread.send(signo )	O
can	O
also	O
be	O
called	O
as	O
just	O
thread	O
send	O
signo	O
;	O
and	O
method	O
foo.toString( )	O
can	O
also	O
be	O
called	O
as	O
just	O
foo	O
toString	B-Language
.	O
</s>
<s>
These	O
syntactic	O
relaxations	O
are	O
designed	O
to	O
allow	O
support	O
for	O
domain-specific	B-Language
languages	I-Language
.	O
</s>
<s>
Generic	B-Language
types	I-Language
are	O
written	O
as	O
e.g.	O
</s>
<s>
List[String]	O
rather	O
than	O
Java	B-Language
's	O
Listxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx1	O
.	O
</s>
<s>
Instead	O
of	O
the	O
pseudo-type	O
void	O
,	O
Scala	B-Application
has	O
the	O
actual	O
singleton	O
class	O
Unit	O
(	O
see	O
below	O
)	O
.	O
</s>
<s>
The	O
following	O
example	O
contrasts	O
the	O
definition	O
of	O
classes	O
in	O
Java	B-Language
and	O
Scala	B-Application
.	O
</s>
<s>
//	O
Java	B-Language
:	O
</s>
<s>
The	O
code	O
above	O
shows	O
some	O
of	O
the	O
conceptual	O
differences	O
between	O
Java	B-Language
and	O
Scala	B-Application
's	O
handling	O
of	O
classes	O
:	O
</s>
<s>
Scala	B-Application
has	O
no	O
static	O
variables	O
or	O
methods	O
.	O
</s>
<s>
In	O
place	O
of	O
constructor	O
parameters	O
,	O
Scala	B-Application
has	O
class	O
parameters	O
,	O
which	O
are	O
placed	O
on	O
the	O
class	O
,	O
similar	O
to	O
parameters	O
to	O
a	O
function	O
.	O
</s>
<s>
Note	O
that	O
alternative	O
constructors	O
can	O
also	O
be	O
declared	O
,	O
as	O
in	O
Java	B-Language
.	O
</s>
<s>
Code	O
that	O
would	O
go	B-Application
into	O
the	O
default	O
constructor	O
(	O
other	O
than	O
initializing	O
the	O
member	O
variables	O
)	O
goes	O
directly	O
at	O
class	O
level	O
.	O
</s>
<s>
Default	O
visibility	O
in	O
Scala	B-Application
is	O
public	O
.	O
</s>
<s>
Scala	B-Application
has	O
the	O
same	O
compiling	B-Language
model	O
as	O
Java	B-Language
and	O
C#	B-Application
,	O
namely	O
separate	O
compiling	B-Language
and	O
dynamic	B-Language
class	I-Language
loading	I-Language
,	O
so	O
that	O
Scala	B-Application
code	O
can	O
call	O
Java	B-Language
libraries	O
.	O
</s>
<s>
Scala	B-Application
's	O
operational	O
characteristics	O
are	O
the	O
same	O
as	O
Java	B-Language
's	O
.	O
</s>
<s>
The	O
Scala	B-Application
compiler	B-Language
generates	O
byte	O
code	O
that	O
is	O
nearly	O
identical	O
to	O
that	O
generated	O
by	O
the	O
Java	B-Language
compiler	B-Language
.	O
</s>
<s>
In	O
fact	O
,	O
Scala	B-Application
code	O
can	O
be	O
decompiled	B-Application
to	O
readable	O
Java	B-Language
code	I-Language
,	O
with	O
the	O
exception	O
of	O
certain	O
constructor	O
operations	O
.	O
</s>
<s>
To	O
the	O
Java	B-Language
virtual	I-Language
machine	I-Language
(	O
JVM	B-Language
)	O
,	O
Scala	B-Application
code	O
and	O
Java	B-Language
code	I-Language
are	O
indistinguishable	O
.	O
</s>
<s>
The	O
only	O
difference	O
is	O
one	O
extra	O
runtime	O
library	O
,	O
scala-library.jar	O
.	O
</s>
<s>
Scala	B-Application
adds	O
a	O
large	O
number	O
of	O
features	O
compared	O
with	O
Java	B-Language
,	O
and	O
has	O
some	O
fundamental	O
differences	O
in	O
its	O
underlying	O
model	O
of	O
expressions	O
and	O
types	O
,	O
which	O
make	O
the	O
language	O
theoretically	O
cleaner	O
and	O
eliminate	O
several	O
corner	O
cases	O
in	O
Java	B-Language
.	O
</s>
<s>
From	O
the	O
Scala	B-Application
perspective	O
,	O
this	O
is	O
practically	O
important	O
because	O
several	O
added	O
features	O
in	O
Scala	B-Application
are	O
also	O
available	O
in	O
C#	B-Application
.	O
</s>
<s>
As	O
mentioned	O
above	O
,	O
Scala	B-Application
has	O
a	O
good	O
deal	O
of	O
syntactic	O
flexibility	O
,	O
compared	O
with	O
Java	B-Language
.	O
</s>
<s>
This	O
is	O
used	O
for	O
collection	B-Application
classes	O
and	O
extends	O
to	O
many	O
other	O
cases	O
,	O
such	O
as	O
STM	B-Operating_System
cells	O
.	O
</s>
<s>
Scala	B-Application
distinguishes	O
between	O
no-parens	O
(	O
def	O
foo	O
=	O
42	O
)	O
and	O
empty-parens	O
(	O
def	O
foo( )	O
=	O
42	O
)	O
methods	O
.	O
</s>
<s>
When	O
calling	O
an	O
empty-parens	O
method	O
,	O
the	O
parentheses	O
may	O
be	O
omitted	O
,	O
which	O
is	O
useful	O
when	O
calling	O
into	O
Java	B-Language
libraries	O
that	O
do	O
not	O
know	O
this	O
distinction	O
,	O
e.g.	O
,	O
using	O
foo.toString	O
instead	O
of	O
foo.toString( )	O
.	O
</s>
<s>
For	O
example	O
,	O
breakable	O
{	O
...	O
if	O
(	O
...	O
)	O
break( )	O
...	O
}	O
looks	O
as	O
if	O
breakable	O
was	O
a	O
language	O
defined	O
keyword	O
,	O
but	O
really	O
is	O
just	O
a	O
method	O
taking	O
a	O
thunk	B-Application
argument	O
.	O
</s>
<s>
Methods	O
that	O
take	O
thunks	B-Application
or	O
functions	O
often	O
place	O
these	O
in	O
a	O
second	O
parameter	O
list	O
,	O
allowing	O
to	O
mix	O
parentheses	O
and	O
curly	O
braces	O
syntax	O
:	O
Vector.fill(4 )	O
{	O
math.random	O
}	O
is	O
the	O
same	O
as	O
Vector.fill(4 )	O
(	O
math.random	O
)	O
.	O
</s>
<s>
By	O
themselves	O
,	O
these	O
may	O
seem	O
like	O
questionable	O
choices	O
,	O
but	O
collectively	O
they	O
serve	O
the	O
purpose	O
of	O
allowing	O
domain-specific	B-Language
languages	I-Language
to	O
be	O
defined	O
in	O
Scala	B-Application
without	O
needing	O
to	O
extend	O
the	O
compiler	B-Language
.	O
</s>
<s>
For	O
example	O
,	O
Erlang	B-Operating_System
's	O
special	O
syntax	O
for	O
sending	O
a	O
message	O
to	O
an	O
actor	O
,	O
i.e.	O
</s>
<s>
message	O
can	O
be	O
(	O
and	O
is	O
)	O
implemented	O
in	O
a	O
Scala	B-Application
library	O
without	O
needing	O
language	O
extensions	O
.	O
</s>
<s>
Java	B-Language
makes	O
a	O
sharp	O
distinction	O
between	O
primitive	O
types	O
(	O
e.g.	O
</s>
<s>
Only	O
reference	O
types	O
are	O
part	O
of	O
the	O
inheritance	O
scheme	B-Language
,	O
deriving	O
from	O
java.lang.Object	O
.	O
</s>
<s>
In	O
Scala	B-Application
,	O
all	O
types	O
inherit	O
from	O
a	O
top-level	O
class	O
Any	O
,	O
whose	O
immediate	O
children	O
are	O
AnyVal	O
(	O
value	O
types	O
,	O
such	O
as	O
Int	O
and	O
Boolean	O
)	O
and	O
AnyRef	O
(	O
reference	O
types	O
,	O
as	O
in	O
Java	B-Language
)	O
.	O
</s>
<s>
This	O
means	O
that	O
the	O
Java	B-Language
distinction	O
between	O
primitive	O
types	O
and	O
boxed	O
types	O
(	O
e.g.	O
</s>
<s>
int	O
vs.	O
Integer	O
)	O
is	O
not	O
present	O
in	O
Scala	B-Application
;	O
boxing	O
and	O
unboxing	O
is	O
completely	O
transparent	O
to	O
the	O
user	O
.	O
</s>
<s>
Scala	B-Application
2.10	O
allows	O
for	O
new	O
value	O
types	O
to	O
be	O
defined	O
by	O
the	O
user	O
.	O
</s>
<s>
Instead	O
of	O
the	O
Java	B-Language
"	O
foreach	O
"	O
loops	O
for	O
looping	O
through	O
an	O
iterator	O
,	O
Scala	B-Application
has	O
for-expressions	O
,	O
which	O
are	O
similar	O
to	O
list	B-Language
comprehensions	I-Language
in	O
languages	O
such	O
as	O
Haskell	B-Language
,	O
or	O
a	O
combination	O
of	O
list	B-Language
comprehensions	I-Language
and	O
generator	B-Language
expressions	I-Language
in	O
Python	B-Language
.	O
</s>
<s>
For-expressions	O
using	O
the	O
yield	O
keyword	O
allow	O
a	O
new	O
collection	B-Application
to	O
be	O
generated	O
by	O
iterating	O
over	O
an	O
existing	O
one	O
,	O
returning	O
a	O
new	O
collection	B-Application
of	O
the	O
same	O
type	O
.	O
</s>
<s>
They	O
are	O
translated	O
by	O
the	O
compiler	B-Language
into	O
a	O
series	O
of	O
map	O
,	O
flatMap	O
and	O
filter	O
calls	O
.	O
</s>
<s>
Where	O
yield	O
is	O
not	O
used	O
,	O
the	O
code	O
approximates	O
to	O
an	O
imperative-style	O
loop	O
,	O
by	O
translating	O
to	O
foreach	O
.	O
</s>
<s>
The	O
method	O
to	O
is	O
rather	O
defined	O
in	O
the	O
standard	O
Scala	B-Application
library	O
as	O
an	O
extension	O
method	O
on	O
integers	O
,	O
using	O
a	O
technique	O
known	O
as	O
implicit	O
conversions	O
that	O
allows	O
new	O
methods	O
to	O
be	O
added	O
to	O
existing	O
types	O
.	O
)	O
</s>
<s>
Expression	O
(	O
mention	O
,	O
times	O
)	O
<	O
-	O
mentions	O
is	O
an	O
example	O
of	O
pattern	B-Language
matching	I-Language
(	O
see	O
below	O
)	O
.	O
</s>
<s>
Iterating	O
over	O
a	O
map	O
returns	O
a	O
set	O
of	O
key-value	O
tuples	O
,	O
and	O
pattern-matching	B-Language
allows	O
the	O
tuples	O
to	O
easily	O
be	O
destructured	O
into	O
separate	O
variables	O
for	O
the	O
key	O
and	O
value	O
.	O
</s>
<s>
Note	O
that	O
if	O
mentions	O
instead	O
held	O
a	O
list	O
,	O
set	O
,	O
array	O
or	O
other	O
collection	B-Application
of	O
tuples	O
,	O
exactly	O
the	O
same	O
code	O
above	O
would	O
yield	O
a	O
new	O
collection	B-Application
of	O
the	O
same	O
type	O
.	O
</s>
<s>
While	O
supporting	O
all	O
of	O
the	O
object-oriented	B-Language
features	O
available	O
in	O
Java	B-Language
(	O
and	O
in	O
fact	O
,	O
augmenting	O
them	O
in	O
various	O
ways	O
)	O
,	O
Scala	B-Application
also	O
provides	O
a	O
large	O
number	O
of	O
capabilities	O
that	O
are	O
normally	O
found	O
only	O
in	O
functional	B-Language
programming	I-Language
languages	I-Language
.	O
</s>
<s>
Together	O
,	O
these	O
features	O
allow	O
Scala	B-Application
programs	O
to	O
be	O
written	O
in	O
an	O
almost	O
completely	O
functional	B-Language
style	O
and	O
also	O
allow	O
functional	B-Language
and	O
object-oriented	B-Language
styles	O
to	O
be	O
mixed	O
.	O
</s>
<s>
Unlike	O
C	B-Language
or	O
Java	B-Language
,	O
but	O
similar	O
to	O
languages	O
such	O
as	O
Lisp	B-Language
,	O
Scala	B-Application
makes	O
no	O
distinction	O
between	O
statements	O
and	O
expressions	O
.	O
</s>
<s>
Functions	O
that	O
would	O
be	O
declared	O
as	O
returning	O
void	O
in	O
C	B-Language
or	O
Java	B-Language
,	O
and	O
statements	O
like	O
while	O
that	O
logically	O
do	O
not	O
return	O
a	O
value	O
,	O
are	O
in	O
Scala	B-Application
considered	O
to	O
return	O
the	O
type	O
Unit	O
,	O
which	O
is	O
a	O
singleton	O
type	O
,	O
with	O
only	O
one	O
object	O
of	O
that	O
type	O
.	O
</s>
<s>
the	O
throw	O
operator	O
or	O
a	O
function	O
that	O
always	O
exits	O
non-locally	B-General_Concept
using	O
an	O
exception	O
)	O
logically	O
have	O
return	O
type	O
Nothing	O
,	O
a	O
special	O
type	O
containing	O
no	O
objects	O
;	O
that	O
is	O
,	O
a	O
bottom	O
type	O
,	O
i.e.	O
</s>
<s>
This	O
means	O
that	O
such	O
a	O
block	O
of	O
code	O
can	O
be	O
inserted	O
wherever	O
an	O
expression	O
is	O
desired	O
,	O
obviating	O
the	O
need	O
for	O
a	O
ternary	O
operator	O
in	O
Scala	B-Application
:	O
</s>
<s>
//	O
Java	B-Language
:	O
</s>
<s>
x	O
+	O
'	O
A	O
 '	O
-	O
10	O
:	O
x	O
+	O
'	O
0	O
 '	O
)	O
;	O
//	O
Scala	B-Application
:	O
</s>
<s>
For	O
similar	O
reasons	O
,	O
return	O
statements	O
are	O
unnecessary	O
in	O
Scala	B-Application
,	O
and	O
in	O
fact	O
are	O
discouraged	O
.	O
</s>
<s>
As	O
in	O
Lisp	B-Language
,	O
the	O
last	O
expression	O
in	O
a	O
block	O
of	O
code	O
is	O
the	O
value	O
of	O
that	O
block	O
of	O
code	O
,	O
and	O
if	O
the	O
block	O
of	O
code	O
is	O
the	O
body	O
of	O
a	O
function	O
,	O
it	O
will	O
be	O
returned	O
by	O
the	O
function	O
.	O
</s>
<s>
Due	O
to	O
type	O
inference	O
,	O
the	O
type	O
of	O
variables	O
,	O
function	O
return	O
values	O
,	O
and	O
many	O
other	O
expressions	O
can	O
typically	O
be	O
omitted	O
,	O
as	O
the	O
compiler	B-Language
can	O
deduce	O
it	O
.	O
</s>
<s>
Examples	O
are	O
val	O
x	O
=	O
"	O
foo	O
"	O
(	O
for	O
an	O
immutable	B-Application
constant	O
or	O
immutable	B-Application
object	I-Application
)	O
or	O
var	O
x	O
=	O
1.5	O
(	O
for	O
a	O
variable	O
whose	O
value	O
can	O
later	O
be	O
changed	O
)	O
.	O
</s>
<s>
Type	O
inference	O
in	O
Scala	B-Application
is	O
essentially	O
local	O
,	O
in	O
contrast	O
to	O
the	O
more	O
global	O
Hindley-Milner	B-Algorithm
algorithm	O
used	O
in	O
Haskell	B-Language
,	O
ML	B-Language
and	O
other	O
more	O
purely	O
functional	B-Language
languages	I-Language
.	O
</s>
<s>
This	O
is	O
done	O
to	O
facilitate	O
object-oriented	B-Language
programming	I-Language
.	O
</s>
<s>
In	O
Scala	B-Application
,	O
functions	O
are	O
objects	O
,	O
and	O
a	O
convenient	O
syntax	O
exists	O
for	O
specifying	O
anonymous	B-General_Concept
functions	I-General_Concept
.	O
</s>
<s>
It	O
is	O
equivalent	O
to	O
the	O
Lisp	B-Language
form	O
(	O
lambda	B-General_Concept
(	O
x	O
)	O
(	O
<	O
x	O
2	O
)	O
)	O
.	O
</s>
<s>
Anonymous	B-General_Concept
functions	I-General_Concept
behave	O
as	O
true	O
closures	B-Language
in	O
that	O
they	O
automatically	O
capture	O
any	O
variables	O
that	O
are	O
lexically	O
available	O
in	O
the	O
environment	O
of	O
the	O
enclosing	O
function	O
.	O
</s>
<s>
Those	O
variables	O
will	O
be	O
available	O
even	O
after	O
the	O
enclosing	O
function	O
returns	O
,	O
and	O
unlike	O
in	O
the	O
case	O
of	O
Java	B-Language
's	O
anonymous	O
inner	O
classes	O
do	O
not	O
need	O
to	O
be	O
declared	O
as	O
final	O
.	O
</s>
<s>
(	O
It	O
is	O
even	O
possible	O
to	O
modify	O
such	O
variables	O
if	O
they	O
are	O
mutable	B-Application
,	O
and	O
the	O
modified	O
value	O
will	O
be	O
available	O
the	O
next	O
time	O
the	O
anonymous	B-General_Concept
function	I-General_Concept
is	O
called	O
.	O
)	O
</s>
<s>
An	O
even	O
shorter	O
form	O
of	O
anonymous	B-General_Concept
function	I-General_Concept
uses	O
placeholder	O
variables	O
:	O
For	O
example	O
,	O
the	O
following	O
:	O
</s>
<s>
Scala	B-Application
enforces	O
a	O
distinction	O
between	O
immutable	B-Application
and	O
mutable	B-Application
variables	I-Application
.	O
</s>
<s>
Mutable	B-Application
variables	I-Application
are	O
declared	O
using	O
the	O
var	O
keyword	O
and	O
immutable	B-Application
values	I-Application
are	O
declared	O
using	O
the	O
val	O
keyword	O
.	O
</s>
<s>
A	O
variable	O
declared	O
using	O
the	O
val	O
keyword	O
cannot	O
be	O
reassigned	O
in	O
the	O
same	O
way	O
that	O
a	O
variable	O
declared	O
using	O
the	O
final	O
keyword	O
ca	O
n't	O
be	O
reassigned	O
in	O
Java	B-Language
.	O
</s>
<s>
vals	O
are	O
only	O
shallowly	O
immutable	B-Application
,	O
that	O
is	O
,	O
an	O
object	O
referenced	O
by	O
a	O
val	O
is	O
not	O
guaranteed	O
to	O
itself	O
be	O
immutable	B-Application
.	O
</s>
<s>
Immutable	B-Application
classes	O
are	O
encouraged	O
by	O
convention	O
however	O
,	O
and	O
the	O
Scala	B-Application
standard	O
library	O
provides	O
a	O
rich	O
set	O
of	O
immutable	B-Application
collection	B-Application
classes	O
.	O
</s>
<s>
Scala	B-Application
provides	O
mutable	B-Application
and	O
immutable	B-Application
variants	O
of	O
most	O
collection	B-Application
classes	O
,	O
and	O
the	O
immutable	B-Application
version	O
is	O
always	O
used	O
unless	O
the	O
mutable	B-Application
version	O
is	O
explicitly	O
imported	O
.	O
</s>
<s>
The	O
immutable	B-Application
variants	O
are	O
persistent	B-Application
data	I-Application
structures	I-Application
that	O
always	O
return	O
an	O
updated	O
copy	O
of	O
an	O
old	O
object	O
instead	O
of	O
updating	O
the	O
old	O
object	O
destructively	O
in	O
place	O
.	O
</s>
<s>
An	O
example	O
of	O
this	O
is	O
immutable	B-Application
linked	O
lists	O
where	O
prepending	O
an	O
element	O
to	O
a	O
list	O
is	O
done	O
by	O
returning	O
a	O
new	O
list	O
node	O
consisting	O
of	O
the	O
element	O
and	O
a	O
reference	O
to	O
the	O
list	O
tail	O
.	O
</s>
<s>
This	O
allows	O
for	O
very	O
easy	O
concurrency	B-Architecture
—	O
no	O
locks	O
are	O
needed	O
as	O
no	O
shared	O
objects	O
are	O
ever	O
modified	O
.	O
</s>
<s>
In	O
other	O
words	O
,	O
Scala	B-Application
evaluates	O
expressions	O
as	O
soon	O
as	O
they	O
are	O
available	O
,	O
rather	O
than	O
as	O
needed	O
.	O
</s>
<s>
Non-strict	O
collections	O
of	O
various	O
types	O
also	O
exist	O
(	O
such	O
as	O
the	O
type	O
Stream	O
,	O
a	O
non-strict	O
linked	O
list	O
)	O
,	O
and	O
any	O
collection	B-Application
can	O
be	O
made	O
non-strict	O
with	O
the	O
view	O
method	O
.	O
</s>
<s>
Functional	B-Language
programming	I-Language
languages	I-Language
commonly	O
provide	O
tail	B-Language
call	I-Language
optimization	I-Language
to	O
allow	O
for	O
extensive	O
use	O
of	O
recursion	O
without	O
stack	B-Error_Name
overflow	I-Error_Name
problems	O
.	O
</s>
<s>
Limitations	O
in	O
Java	B-Language
bytecode	I-Language
complicate	O
tail	B-Language
call	I-Language
optimization	I-Language
on	O
the	O
JVM	B-Language
.	O
</s>
<s>
In	O
general	O
,	O
a	O
function	O
that	O
calls	O
itself	O
with	O
a	O
tail	B-Language
call	I-Language
can	O
be	O
optimized	O
,	O
but	O
mutually	O
recursive	O
functions	O
cannot	O
.	O
</s>
<s>
Trampolines	B-General_Concept
have	O
been	O
suggested	O
as	O
a	O
workaround	O
.	O
</s>
<s>
Trampoline	B-General_Concept
support	O
has	O
been	O
provided	O
by	O
the	O
Scala	B-Application
library	O
with	O
the	O
object	O
scala.util.control.TailCalls	O
since	O
Scala	B-Application
2.8.0	O
(	O
released	O
14	O
July	O
2010	O
)	O
.	O
</s>
<s>
A	O
function	O
may	O
optionally	O
be	O
annotated	O
with	O
@tailrec	O
,	O
in	O
which	O
case	O
it	O
will	O
not	O
compile	B-Language
unless	O
it	O
is	O
tail	B-Language
recursive	I-Language
.	O
</s>
<s>
Scala	B-Application
has	O
built-in	O
support	O
for	O
pattern	B-Language
matching	I-Language
,	O
which	O
can	O
be	O
thought	O
of	O
as	O
a	O
more	O
sophisticated	O
,	O
extensible	O
version	O
of	O
a	O
switch	O
statement	O
,	O
where	O
arbitrary	O
data	O
types	O
can	O
be	O
matched	O
(	O
rather	O
than	O
just	O
simple	O
types	O
like	O
integers	O
,	O
booleans	O
and	O
strings	O
)	O
,	O
including	O
arbitrary	O
nesting	O
.	O
</s>
<s>
A	O
special	O
type	O
of	O
class	O
known	O
as	O
a	O
case	O
class	O
is	O
provided	O
,	O
which	O
includes	O
automatic	O
support	O
for	O
pattern	B-Language
matching	I-Language
and	O
can	O
be	O
used	O
to	O
model	O
the	O
algebraic	O
data	O
types	O
used	O
in	O
many	O
functional	B-Language
programming	I-Language
languages	I-Language
.	O
</s>
<s>
(	O
From	O
the	O
perspective	O
of	O
Scala	B-Application
,	O
a	O
case	O
class	O
is	O
simply	O
a	O
normal	O
class	O
for	O
which	O
the	O
compiler	B-Language
automatically	O
adds	O
certain	O
behaviors	O
that	O
could	O
also	O
be	O
provided	O
manually	O
,	O
e.g.	O
,	O
definitions	O
of	O
methods	O
providing	O
for	O
deep	O
comparisons	O
and	O
hashing	O
,	O
and	O
destructuring	O
a	O
case	O
class	O
on	O
its	O
constructor	O
parameters	O
during	O
pattern	B-Language
matching	I-Language
.	O
)	O
</s>
<s>
An	O
example	O
of	O
a	O
definition	O
of	O
the	O
quicksort	B-Algorithm
algorithm	O
using	O
pattern	B-Language
matching	I-Language
is	O
this	O
:	O
</s>
<s>
This	O
uses	O
the	O
same	O
divide-and-conquer	B-Algorithm
strategy	O
of	O
mergesort	B-Algorithm
and	O
other	O
fast	O
sorting	O
algorithms	O
.	O
</s>
<s>
The	O
match	O
operator	O
is	O
used	O
to	O
do	O
pattern	B-Language
matching	I-Language
on	O
the	O
object	O
stored	O
in	O
list	O
.	O
</s>
<s>
Note	O
that	O
these	O
variables	O
are	O
read-only	O
,	O
and	O
are	O
semantically	O
very	O
similar	O
to	O
variable	O
bindings	O
established	O
using	O
the	O
let	O
operator	O
in	O
Lisp	B-Language
and	O
Scheme	B-Language
.	O
</s>
<s>
Pattern	B-Language
matching	I-Language
also	O
happens	O
in	O
local	O
variable	O
declarations	O
.	O
</s>
<s>
(	O
Tuples	O
differ	O
from	O
other	O
types	O
of	O
containers	B-Application
,	O
e.g.	O
</s>
<s>
Pattern	B-Language
matching	I-Language
is	O
the	O
easiest	O
way	O
of	O
fetching	O
the	O
two	O
parts	O
of	O
the	O
tuple	O
.	O
</s>
<s>
The	O
form	O
_	O
<	O
pivot	O
is	O
a	O
declaration	O
of	O
an	O
anonymous	B-General_Concept
function	I-General_Concept
with	O
a	O
placeholder	O
variable	O
;	O
see	O
the	O
section	O
above	O
on	O
anonymous	B-General_Concept
functions	I-General_Concept
.	O
</s>
<s>
The	O
list	O
operators	O
::	O
(	O
which	O
adds	O
an	O
element	O
onto	O
the	O
beginning	O
of	O
a	O
list	O
,	O
similar	O
to	O
cons	O
in	O
Lisp	B-Language
and	O
Scheme	B-Language
)	O
and	O
:::	O
(	O
which	O
appends	O
two	O
lists	O
together	O
,	O
similar	O
to	O
append	O
in	O
Lisp	B-Language
and	O
Scheme	B-Language
)	O
both	O
appear	O
.	O
</s>
<s>
In	O
the	O
pattern-matching	B-Language
example	O
above	O
,	O
the	O
body	O
of	O
the	O
match	O
operator	O
is	O
a	O
partial	B-Algorithm
function	I-Algorithm
,	O
which	O
consists	O
of	O
a	O
series	O
of	O
case	O
expressions	O
,	O
with	O
the	O
first	O
matching	O
expression	O
prevailing	O
,	O
similar	O
to	O
the	O
body	O
of	O
a	O
switch	O
statement	O
.	O
</s>
<s>
Partial	B-Algorithm
functions	I-Algorithm
are	O
also	O
used	O
in	O
the	O
exception-handling	O
portion	O
of	O
a	O
try	O
statement	O
:	O
</s>
<s>
Finally	O
,	O
a	O
partial	B-Algorithm
function	I-Algorithm
can	O
be	O
used	O
alone	O
,	O
and	O
the	O
result	O
of	O
calling	O
it	O
is	O
equivalent	O
to	O
doing	O
a	O
match	O
over	O
it	O
.	O
</s>
<s>
For	O
example	O
,	O
the	O
prior	O
code	O
for	O
quicksort	B-Algorithm
can	O
be	O
written	O
thus	O
:	O
</s>
<s>
Here	O
a	O
read-only	O
variable	O
is	O
declared	O
whose	O
type	O
is	O
a	O
function	O
from	O
lists	O
of	O
integers	O
to	O
lists	O
of	O
integers	O
,	O
and	O
bind	O
it	O
to	O
a	O
partial	B-Algorithm
function	I-Algorithm
.	O
</s>
<s>
(	O
Note	O
that	O
the	O
single	O
parameter	O
of	O
the	O
partial	B-Algorithm
function	I-Algorithm
is	O
never	O
explicitly	O
declared	O
or	O
named	O
.	O
)	O
</s>
<s>
Scala	B-Application
is	O
a	O
pure	O
object-oriented	B-Language
language	I-Language
in	O
the	O
sense	O
that	O
every	O
value	O
is	O
an	O
object	O
.	O
</s>
<s>
Class	O
abstractions	O
are	O
extended	O
by	O
subclassing	O
and	O
by	O
a	O
flexible	O
mixin-based	O
composition	O
mechanism	O
to	O
avoid	O
the	O
problems	O
of	O
multiple	B-Application
inheritance	I-Application
.	O
</s>
<s>
Traits	O
are	O
Scala	B-Application
's	O
replacement	O
for	O
Java	B-Language
's	O
interfaces	B-Application
.	O
</s>
<s>
Interfaces	B-Application
in	O
Java	B-Language
versions	O
under	O
8	O
are	O
highly	O
restricted	O
,	O
able	O
only	O
to	O
contain	O
abstract	O
function	O
declarations	O
.	O
</s>
<s>
This	O
has	O
led	O
to	O
criticism	O
that	O
providing	O
convenience	O
methods	O
in	O
interfaces	B-Application
is	O
awkward	O
(	O
the	O
same	O
methods	O
must	O
be	O
reimplemented	O
in	O
every	O
implementation	O
)	O
,	O
and	O
extending	O
a	O
published	O
interface	O
in	O
a	O
backwards-compatible	O
way	O
is	O
impossible	O
.	O
</s>
<s>
Traits	O
are	O
similar	O
to	O
mixin	B-Language
classes	I-Language
in	O
that	O
they	O
have	O
nearly	O
all	O
the	O
power	O
of	O
a	O
regular	O
abstract	O
class	O
,	O
lacking	O
only	O
class	O
parameters	O
(	O
Scala	B-Application
's	O
equivalent	O
to	O
Java	B-Language
's	O
constructor	O
parameters	O
)	O
,	O
since	O
traits	O
are	O
always	O
mixed	O
in	O
with	O
a	O
class	O
.	O
</s>
<s>
In	O
other	O
languages	O
,	O
a	O
similar	O
effect	O
could	O
be	O
achieved	O
at	O
compile-time	O
with	O
a	O
long	O
linear	O
chain	O
of	O
implementation	O
inheritance	O
,	O
but	O
with	O
the	O
disadvantage	O
compared	O
to	O
Scala	B-Application
that	O
one	O
linear	O
inheritance	O
chain	O
would	O
have	O
to	O
be	O
declared	O
for	O
each	O
possible	O
combination	O
of	O
the	O
mix-ins	O
.	O
</s>
<s>
Scala	B-Application
is	O
equipped	O
with	O
an	O
expressive	O
static	O
type	O
system	O
that	O
mostly	O
enforces	O
the	O
safe	O
and	O
coherent	O
use	O
of	O
abstractions	O
.	O
</s>
<s>
Scala	B-Application
is	O
able	O
to	O
infer	O
types	O
by	O
use	O
.	O
</s>
<s>
Static	O
types	O
need	O
not	O
be	O
explicitly	O
declared	O
unless	O
a	O
compiler	B-Language
error	O
indicates	O
the	O
need	O
.	O
</s>
<s>
A	O
common	O
technique	O
in	O
Scala	B-Application
,	O
known	O
as	O
"	O
enrich	O
my	O
library	O
"	O
(	O
originally	O
termed	O
"	O
pimp	B-Device
my	I-Device
library	I-Device
"	O
by	O
Martin	O
Odersky	O
in	O
2006	O
;	O
concerns	O
were	O
raised	O
about	O
this	O
phrasing	O
due	O
to	O
its	O
negative	O
connotations	O
and	O
immaturity	O
)	O
,	O
allows	O
new	O
methods	O
to	O
be	O
used	O
as	O
if	O
they	O
were	O
added	O
to	O
existing	O
types	O
.	O
</s>
<s>
This	O
is	O
similar	O
to	O
the	O
C#	B-Application
concept	O
of	O
extension	O
methods	O
but	O
more	O
powerful	O
,	O
because	O
the	O
technique	O
is	O
not	O
limited	O
to	O
adding	O
methods	O
and	O
can	O
,	O
for	O
instance	O
,	O
be	O
used	O
to	O
implement	O
new	O
interfaces	B-Application
.	O
</s>
<s>
In	O
Scala	B-Application
,	O
this	O
technique	O
involves	O
declaring	O
an	O
implicit	O
conversion	O
from	O
the	O
type	O
"	O
receiving	O
"	O
the	O
method	O
to	O
a	O
new	O
type	O
(	O
typically	O
,	O
a	O
class	O
)	O
that	O
wraps	O
the	O
original	O
type	O
and	O
provides	O
the	O
additional	O
method	O
.	O
</s>
<s>
If	O
a	O
method	O
cannot	O
be	O
found	O
for	O
a	O
given	O
type	O
,	O
the	O
compiler	B-Language
automatically	O
searches	O
for	O
any	O
applicable	O
implicit	O
conversions	O
to	O
types	O
that	O
provide	O
the	O
method	O
in	O
question	O
.	O
</s>
<s>
Scala	B-Application
's	O
standard	O
library	O
includes	O
support	O
for	O
futures	B-Operating_System
and	I-Operating_System
promises	I-Operating_System
,	O
in	O
addition	O
to	O
the	O
standard	O
Java	B-Language
concurrency	B-Architecture
APIs	O
.	O
</s>
<s>
Originally	O
,	O
it	O
also	O
included	O
support	O
for	O
the	O
actor	B-Application
model	I-Application
,	O
which	O
is	O
now	O
available	O
as	O
a	O
separate	O
source-available	B-License
platform	O
Akka	B-Language
licensed	O
by	O
Lightbend	O
Inc	O
.	O
Akka	B-Language
actors	O
may	O
be	O
distributed	B-Architecture
or	O
combined	O
with	O
software	B-Operating_System
transactional	I-Operating_System
memory	I-Operating_System
(	O
transactors	O
)	O
.	O
</s>
<s>
Alternative	O
communicating	O
sequential	O
processes	O
(	O
CSP	O
)	O
implementations	O
for	O
channel-based	O
message	O
passing	O
are	O
Communicating	O
Scala	B-Application
Objects	O
,	O
or	O
simply	O
via	O
JCSP	B-Language
.	O
</s>
<s>
An	O
Actor	O
is	O
like	O
a	O
thread	O
instance	O
with	O
a	O
mailbox	B-Operating_System
.	O
</s>
<s>
Scala	B-Application
also	O
comes	O
with	O
built-in	O
support	O
for	O
data-parallel	O
programming	O
in	O
the	O
form	O
of	O
Parallel	O
Collections	O
integrated	O
into	O
its	O
Standard	O
Library	O
since	O
version	O
2.9.0	O
.	O
</s>
<s>
Besides	O
futures	B-Operating_System
and	I-Operating_System
promises	I-Operating_System
,	O
actor	O
support	O
,	O
and	O
data	B-Operating_System
parallelism	I-Operating_System
,	O
Scala	B-Application
also	O
supports	O
asynchronous	O
programming	O
with	O
software	B-Operating_System
transactional	I-Operating_System
memory	I-Operating_System
,	O
and	O
event	O
streams	O
.	O
</s>
<s>
The	O
most	O
well-known	O
open-source	O
cluster-computing	O
solution	O
written	O
in	O
Scala	B-Application
is	O
Apache	B-Language
Spark	I-Language
.	O
</s>
<s>
Additionally	O
,	O
Apache	B-Language
Kafka	I-Language
,	O
the	O
publish	B-Operating_System
–	I-Operating_System
subscribe	I-Operating_System
message	B-Operating_System
queue	I-Operating_System
popular	O
with	O
Spark	B-Language
and	O
other	O
stream	O
processing	O
technologies	O
,	O
is	O
written	O
in	O
Scala	B-Application
.	O
</s>
<s>
There	O
are	O
several	O
ways	O
to	O
test	O
code	O
in	O
Scala	B-Application
.	O
</s>
<s>
ScalaTest	O
supports	O
multiple	O
testing	O
styles	O
and	O
can	O
integrate	O
with	O
Java-based	O
testing	O
frameworks	O
.	O
</s>
<s>
ScalaCheck	O
is	O
a	O
library	O
similar	O
to	O
Haskell	B-Language
's	O
QuickCheck	B-Application
.	O
</s>
<s>
ScalaMock	O
provides	O
support	O
for	O
testing	O
high-order	O
and	O
curried	B-Application
functions	I-Application
.	O
</s>
<s>
JUnit	B-Language
and	O
TestNG	B-Language
are	O
popular	O
testing	O
frameworks	O
written	O
in	O
Java	B-Language
.	O
</s>
<s>
Revision	O
the	O
common	O
,	O
uniform	O
,	O
and	O
all-encompassing	O
framework	O
for	O
collection	B-Application
types	O
.	O
</s>
<s>
scala.actors	O
have	O
been	O
deprecated	O
and	O
the	O
akka	B-Language
implementation	O
is	O
now	O
included	O
in	O
the	O
distribution	O
.	O
</s>
<s>
Scala	B-Application
is	O
often	O
compared	O
with	O
Groovy	B-Application
and	O
Clojure	B-Language
,	O
two	O
other	O
programming	O
languages	O
also	O
using	O
the	O
JVM	B-Language
.	O
</s>
<s>
Substantial	O
differences	O
between	O
these	O
languages	O
exist	O
in	O
the	O
type	O
system	O
,	O
in	O
the	O
extent	O
to	O
which	O
each	O
language	O
supports	O
object-oriented	B-Language
and	O
functional	B-Language
programming	I-Language
,	O
and	O
in	O
the	O
similarity	O
of	O
their	O
syntax	O
to	O
that	O
of	O
Java	B-Language
.	O
</s>
<s>
Scala	B-Application
is	O
statically	O
typed	O
,	O
while	O
both	O
Groovy	B-Application
and	O
Clojure	B-Language
are	O
dynamically	O
typed	O
.	O
</s>
<s>
This	O
makes	O
the	O
type	O
system	O
more	O
complex	O
and	O
difficult	O
to	O
understand	O
but	O
allows	O
almost	O
all	O
type	O
errors	O
to	O
be	O
caught	O
at	O
compile-time	O
and	O
can	O
result	O
in	O
significantly	O
faster	O
execution	O
.	O
</s>
<s>
Regarding	O
speed	O
differences	O
,	O
current	O
versions	O
of	O
Groovy	B-Application
and	O
Clojure	B-Language
allow	O
optional	O
type	O
annotations	O
to	O
help	O
programs	O
avoid	O
the	O
overhead	O
of	O
dynamic	O
typing	O
in	O
cases	O
where	O
types	O
are	O
practically	O
static	O
.	O
</s>
<s>
This	O
overhead	O
is	O
further	O
reduced	O
when	O
using	O
recent	O
versions	O
of	O
the	O
JVM	B-Language
,	O
which	O
has	O
been	O
enhanced	O
with	O
an	O
invoke	O
dynamic	O
instruction	O
for	O
methods	O
that	O
are	O
defined	O
with	O
dynamically	O
typed	O
arguments	O
.	O
</s>
<s>
These	O
advances	O
reduce	O
the	O
speed	O
gap	O
between	O
static	O
and	O
dynamic	O
typing	O
,	O
although	O
a	O
statically	O
typed	O
language	O
,	O
like	O
Scala	B-Application
,	O
is	O
still	O
the	O
preferred	O
choice	O
when	O
execution	O
efficiency	O
is	O
very	O
important	O
.	O
</s>
<s>
Regarding	O
programming	O
paradigms	O
,	O
Scala	B-Application
inherits	O
the	O
object-oriented	B-Language
model	O
of	O
Java	B-Language
and	O
extends	O
it	O
in	O
various	O
ways	O
.	O
</s>
<s>
Groovy	B-Application
,	O
while	O
also	O
strongly	O
object-oriented	B-Language
,	O
is	O
more	O
focused	O
in	O
reducing	O
verbosity	O
.	O
</s>
<s>
In	O
Clojure	B-Language
,	O
object-oriented	B-Language
programming	I-Language
is	O
deemphasised	O
with	O
functional	B-Language
programming	I-Language
being	O
the	O
main	O
strength	O
of	O
the	O
language	O
.	O
</s>
<s>
Scala	B-Application
also	O
has	O
many	O
functional	B-Language
programming	I-Language
facilities	O
,	O
including	O
features	O
found	O
in	O
advanced	O
functional	B-Language
languages	I-Language
like	O
Haskell	B-Language
,	O
and	O
tries	O
to	O
be	O
agnostic	O
between	O
the	O
two	O
paradigms	O
,	O
letting	O
the	O
developer	O
choose	O
between	O
the	O
two	O
paradigms	O
or	O
,	O
more	O
frequently	O
,	O
some	O
combination	O
thereof	O
.	O
</s>
<s>
Regarding	O
syntax	O
similarity	O
with	O
Java	B-Language
,	O
Scala	B-Application
inherits	O
much	O
of	O
Java	B-Language
's	O
syntax	O
,	O
as	O
is	O
the	O
case	O
with	O
Groovy	B-Application
.	O
</s>
<s>
Clojure	B-Language
on	O
the	O
other	O
hand	O
follows	O
the	O
Lisp	B-Language
syntax	O
,	O
which	O
is	O
different	O
in	O
both	O
appearance	O
and	O
philosophy	O
.	O
</s>
<s>
,	O
JVM-based	O
languages	O
such	O
as	O
Clojure	B-Language
,	O
Groovy	B-Application
,	O
,	O
Scala	B-Application
are	O
highly	O
ranked	O
,	O
but	O
still	O
significantly	O
less	O
popular	O
than	O
the	O
original	O
Java	B-Language
language	O
,	O
which	O
is	O
usually	O
ranked	O
in	O
the	O
top	O
three	O
places	O
.	O
</s>
<s>
The	O
Popularity	O
of	O
Programming	O
Language	O
Index	O
,	O
which	O
tracks	O
searches	O
for	O
language	O
tutorials	O
,	O
ranked	O
Scala	B-Application
15th	O
in	O
April	O
2018	O
with	O
a	O
small	O
downward	O
trend	O
,	O
and	O
17th	O
in	O
Jan	O
2021	O
.	O
</s>
<s>
This	O
makes	O
Scala	B-Application
the	O
3rd	O
most	O
popular	O
JVM-based	O
language	O
after	O
Java	B-Language
and	O
Kotlin	B-Language
,	O
ranked	O
12th	O
.	O
</s>
<s>
,	O
it	O
shows	O
Scala	B-Application
in	O
31st	O
place	O
.	O
</s>
<s>
In	O
this	O
ranking	O
,	O
Scala	B-Application
is	O
ahead	O
of	O
Haskell	B-Language
(	O
38th	O
)	O
and	O
Erlang	B-Operating_System
,	O
but	O
below	O
Go	B-Application
(	O
14th	O
)	O
,	O
Swift	B-Application
(	O
15th	O
)	O
,	O
and	O
Perl	B-Language
(	O
19th	O
)	O
.	O
</s>
<s>
The	O
Rankings	O
,	O
which	O
establishes	O
rankings	O
based	O
on	O
the	O
number	O
of	O
GitHub	B-Application
projects	O
and	O
questions	O
asked	O
on	O
Stack	B-Error_Name
Overflow	I-Error_Name
,	O
ranks	O
Scala	B-Application
14th	O
.	O
</s>
<s>
Here	O
,	O
Scala	B-Application
is	O
placed	O
inside	O
a	O
second-tier	O
group	O
of	O
languages	O
–	O
ahead	O
of	O
Go	B-Application
,	O
PowerShell	B-Application
,	O
and	O
Haskell	B-Language
,	O
and	O
behind	O
Swift	B-Application
,	O
Objective-C	B-Language
,	O
Typescript	B-Language
,	O
and	O
R	B-Language
.	O
</s>
<s>
In	O
the	O
2018	O
edition	O
of	O
the	O
State	O
of	O
Java	B-Language
survey	O
,	O
which	O
collected	O
data	O
from	O
5160	O
developers	O
on	O
various	O
Java-related	O
topics	O
,	O
Scala	B-Application
places	O
third	O
in	O
terms	O
of	O
use	O
of	O
alternative	O
languages	O
on	O
the	O
JVM	B-Language
.	O
</s>
<s>
Relative	O
to	O
the	O
prior	O
year	O
's	O
edition	O
of	O
the	O
survey	O
,	O
Scala	B-Application
's	O
use	O
among	O
alternative	O
JVM	B-Language
languages	I-Language
fell	O
from	O
28.4	O
%	O
to	O
21.5	O
%	O
,	O
overtaken	O
by	O
Kotlin	B-Language
,	O
which	O
rose	O
from	O
11.4	O
%	O
in	O
2017	O
to	O
28.8	O
%	O
in	O
2018	O
.	O
</s>
<s>
Back	O
in	O
2013	O
,	O
when	O
Scala	B-Application
was	O
in	O
version	O
2.10	O
,	O
the	O
ThoughtWorks	B-Application
Technology	O
Radar	O
,	O
which	O
is	O
an	O
opinion	O
based	O
biannual	O
report	O
of	O
a	O
group	O
of	O
senior	O
technologists	O
,	O
recommended	O
Scala	B-Application
adoption	O
in	O
its	O
languages	O
and	O
frameworks	O
category	O
.	O
</s>
<s>
In	O
July	O
2014	O
,	O
this	O
assessment	O
was	O
made	O
more	O
specific	O
and	O
now	O
refers	O
to	O
a	O
“	O
Scala	B-Application
,	O
the	O
good	O
parts	O
”	O
,	O
which	O
is	O
described	O
as	O
“	O
To	O
successfully	O
use	O
Scala	B-Application
,	O
you	O
need	O
to	O
research	O
the	O
language	O
and	O
have	O
a	O
very	O
strong	O
opinion	O
on	O
which	O
parts	O
are	O
right	O
for	O
you	O
,	O
creating	O
your	O
own	O
definition	O
of	O
Scala	B-Application
,	O
the	O
good	O
parts.	O
”	O
.	O
</s>
<s>
In	O
April	O
2009	O
,	O
Twitter	B-Application
announced	O
that	O
it	O
had	O
switched	O
large	O
portions	O
of	O
its	O
backend	O
from	O
Ruby	B-Language
to	O
Scala	B-Application
and	O
intended	O
to	O
convert	O
the	O
rest	O
.	O
</s>
<s>
Tesla	O
,	O
Inc	O
.	O
uses	O
Akka	B-Language
with	O
Scala	B-Application
in	O
the	O
backend	O
of	O
the	O
Tesla	O
Virtual	O
Power	O
Plant	O
.	O
</s>
<s>
Thereby	O
,	O
the	O
Actor	B-Application
model	I-Application
is	O
used	O
for	O
representing	O
and	O
operating	O
devices	O
that	O
together	O
with	O
other	O
components	O
make	O
up	O
an	O
instance	O
of	O
the	O
virtual	O
power	O
plant	O
,	O
and	O
Reactive	B-Language
Streams	I-Language
are	O
used	O
for	O
data	O
collection	B-Application
and	O
data	O
processing	O
.	O
</s>
<s>
Apache	B-Language
Kafka	I-Language
is	O
implemented	O
in	O
Scala	B-Application
with	O
regards	O
to	O
most	O
of	O
its	O
core	O
and	O
other	O
critical	O
parts	O
.	O
</s>
<s>
Gilt	O
uses	O
Scala	B-Application
and	O
Play	B-Language
Framework	I-Language
.	O
</s>
<s>
Foursquare	B-Application
uses	O
Scala	B-Application
and	O
Lift	B-Language
.	O
</s>
<s>
Coursera	O
uses	O
Scala	B-Application
and	O
Play	B-Language
Framework	I-Language
.	O
</s>
<s>
Apple	O
Inc	O
.	O
uses	O
Scala	B-Application
in	O
certain	O
teams	O
,	O
along	O
with	O
Java	B-Language
and	O
the	O
Play	B-Language
framework	I-Language
.	O
</s>
<s>
The	O
Guardian	O
newspaper	O
's	O
high-traffic	O
website	O
guardian.co.uk	O
announced	O
in	O
April	O
2011	O
that	O
it	O
was	O
switching	O
from	O
Java	B-Language
to	O
Scala	B-Application
.	O
</s>
<s>
The	O
New	O
York	O
Times	O
revealed	O
in	O
2014	O
that	O
its	O
internal	O
content	O
management	O
system	O
Blackbeard	O
is	O
built	O
using	O
Scala	B-Application
,	O
Akka	B-Language
,	O
and	O
Play	O
.	O
</s>
<s>
The	O
Huffington	O
Post	O
newspaper	O
started	O
to	O
employ	O
Scala	B-Application
as	O
part	O
of	O
its	O
content	O
delivery	O
system	O
Athena	O
in	O
2013	O
.	O
</s>
<s>
Swiss	O
bank	O
UBS	O
approved	O
Scala	B-Application
for	O
general	O
production	O
use	O
.	O
</s>
<s>
LinkedIn	B-Application
uses	O
the	O
Scalatra	B-Language
microframework	B-Application
to	O
power	O
its	O
Signal	O
API	O
.	O
</s>
<s>
Remember	B-Application
the	I-Application
Milk	I-Application
uses	O
Unfiltered	O
toolkit	O
,	O
Scala	B-Application
and	O
Akka	B-Language
for	O
public	O
API	O
and	O
real-time	O
updates	O
.	O
</s>
<s>
Verizon	B-Application
seeking	O
to	O
make	O
"	O
a	O
next-generation	O
framework	O
"	O
using	O
Scala	B-Application
.	O
</s>
<s>
Airbnb	O
develops	O
open-source	O
machine-learning	O
software	O
"	O
Aerosolve	O
"	O
,	O
written	O
in	O
Java	B-Language
and	O
Scala	B-Application
.	O
</s>
<s>
Zalando	O
moved	O
its	O
technology	O
stack	O
from	O
Java	B-Language
to	O
Scala	B-Application
and	O
Play	O
.	O
</s>
<s>
SoundCloud	O
uses	O
Scala	B-Application
for	O
its	O
back-end	O
,	O
employing	O
technologies	O
such	O
as	O
Finagle	O
(	O
micro	O
services	O
)	O
,	O
Scalding	O
and	O
Spark	B-Language
(	O
data	O
processing	O
)	O
.	O
</s>
<s>
Databricks	O
uses	O
Scala	B-Application
for	O
the	O
Apache	B-Language
Spark	I-Language
Big	O
Data	O
platform	O
.	O
</s>
<s>
Morgan	O
Stanley	O
uses	O
Scala	B-Application
extensively	O
in	O
their	O
finance	O
and	O
asset-related	O
projects	O
.	O
</s>
<s>
There	O
are	O
teams	O
within	O
Google	B-Application
and	O
Alphabet	O
Inc	O
.	O
that	O
use	O
Scala	B-Application
,	O
mostly	O
due	O
to	O
acquisitions	O
such	O
as	O
Firebase	B-General_Concept
and	O
Nest	O
.	O
</s>
<s>
Walmart	O
Canada	O
uses	O
Scala	B-Application
for	O
their	O
back-end	O
platform	O
.	O
</s>
<s>
Duolingo	B-Application
uses	O
Scala	B-Application
for	O
their	O
back-end	O
module	O
that	O
generates	O
lessons	O
.	O
</s>
<s>
HMRC	O
uses	O
Scala	B-Application
for	O
many	O
UK	O
Government	O
tax	O
applications	O
.	O
</s>
<s>
M1	O
Finance	O
uses	O
Scala	B-Application
for	O
their	O
back-end	O
platform	O
.	O
</s>
<s>
In	O
March	O
2015	O
,	O
former	O
VP	O
of	O
the	O
Platform	O
Engineering	O
group	O
at	O
Twitter	B-Application
Raffi	O
Krikorian	O
,	O
stated	O
that	O
he	O
would	O
not	O
have	O
chosen	O
Scala	B-Application
in	O
2011	O
due	O
to	O
its	O
learning	B-General_Concept
curve	I-General_Concept
.	O
</s>
<s>
The	O
same	O
month	O
,	O
LinkedIn	B-Application
SVP	O
Kevin	O
Scott	O
stated	O
their	O
decision	O
to	O
"	O
minimize	O
 [ their ] 	O
dependence	O
on	O
Scala	B-Application
"	O
.	O
</s>
<s>
In	O
November	O
2011	O
,	O
Yammer	B-Protocol
moved	O
away	O
from	O
Scala	B-Application
for	O
reasons	O
that	O
included	O
the	O
learning	B-General_Concept
curve	I-General_Concept
for	O
new	O
team	O
members	O
and	O
incompatibility	O
from	O
one	O
version	O
of	O
the	O
Scala	B-Application
compiler	B-Language
to	O
the	O
next	O
.	O
</s>
