Scala was first publicly released in 2004 by Martin Odersky, then working at École Polytechnique Fédérale de Lausanne in Switzerland. Odersky took part in designing the current generation of the Java compiler javac as well. Scala programs, when compiled, run on the Java Virtual Machine (JVM). Scala is the most popular of all the JVM languages (except for Java.) Like Java, Scala is statically typed. From the perspective of a programmer, this means that variable types will have to be declared (unless they can be inferred by the compiler) and they cannot change during the execution of the program. This is in contrast to dynamic languages, such as Python, where you don't have to specify a variable's type and can assign anything to any variable at runtime. Unlike Java, Scala has strong support for functional programming. Scala draws inspiration from languages such as Haskell, Erlang, and others in this regard.
In this chapter, we will talk about why you would want to use Scala as your primary scientific computing environment. We will consider the advantages it has over other popular programming languages that are used in the scientific computing context. We will then go over Scala packages meant specifically for scientific computing. These will be considered briefly and will be divided into categories depending on what they are used for. Some of these we will consider in detail in later chapters.
Finally, we provide a small introduction on best practices for how to structure, build, test, and distribute your Scala software. This is important even to people who know how to program in Scala already. This chapter introduces concepts that I consider essential, to write scientific software successfully. They are, however, often overlooked by scientists. The reason is that scientists often don't concern themselves with software development techniques; instead, they prefer to get the job done quickly. For example, it is not uncommon to neglect build systems, which are very important no matter what language you are using and are essential when writing software in statically typed, compiled languages. Testing is another area of software development criminally overlooked by the scientists I have had the pleasure to work with. The same is usually true of IDE's, debuggers, and profilers. All of these following topics will be discussed:
Why Scala for scientific computing?
Numerical computing packages for Scala
Data analysis packages for Scala
Other scientific software
Alternatives for carrying out plotting
Using Emacs as the Scala IDE
Profiling Scala code
Debugging Scala code
Building, testing, and distributing your Scala software
Mixing Java and Scala code