Java Magazine, Jan/Feb 2017

ORACLE COM JAVAMAGAZINE JANUARY FEBRUARY 2017 47 jvm languages Scala is a pragmatic object oriented JVM language that integrates a comprehensive set of functional programming FP features such as pattern matching and immutable collections using a compact syntax with powerful type inference It has gained widespread adoption in many diferent industries with some codebases in the millions of lines Thanks to Apache Spark Scala is also widely used in the data science community Interoperability with Java is a core feature of Scala and with version 212 the language now includes the features of the Java 8 platform For example Scala 212 compiles lambdas in the same way as Java 8 Similarly a Scala trait compiles to a Java interface with default methods Scalas Origins Scala was originally developed by Martin Odersky and his research group at the École Polytechnique Fédérale de Lausanne EPFL a leading Swiss technical university Before designing Scala Odersky codesigned Generic Java GJ which brought generics from FP to Java and he developed a compiler for it Sun Microsystems adopted the GJ compiler as the standard javac compiler from version 13 on with its support for generics enabled in Java 5 Meanwhile Odersky and his research group started work on Scala releasing version 20 in 2006 Around 2007 prominent internet startups such as Twitter and Foursquare started to use Scala in production and adoption has grown ever since In 2011 the company Typesafe was founded to drive commercial adoption of Scala as the language for multicore and cloud computing using the Akka middleware framework Today Typesafe is known as Lightbend My team at Lightbend continues to develop the Scala compiler and library in collaboration with an active open source community A third of the commits in the latest release came from the community Other vendors are investing in Scala as well For example JetBrains Scala plugin for IntelliJ IDEA has been downloaded almost 5 million times The Scala Philosophy In this article I explain some of Scalas core concepts and illustrate them with small code snippets I hope to convince you that while some developers consider Scala a big language it actually has a small purely object oriented core so flexible that it can take many diferent shapes The key idea behind Scalas design is that functional and object oriented programming are complementary and thus combine well into a single language While FP is often associated with complicated types and deep math the true appeal of FP in Scala is that it streamlines implementing common tasks in a way that is easier to understand and to scale up The popularity of lambdas in Java 8 is a good example of this ADRIAAN MOORS Scala Deeply Functional Purely Object Oriented A mature practical and type safe language for the JVM

You must have JavaScript enabled to view digital editions.