Machine Learning with Scala

  • by

Scala is a programming language whose development began in 2001 at the University of Lausanne, and which supports both the functional and object-oriented programming paradigms. Martin Odersky contributed significantly to its development. The basis for running Scala code is both the Java Virtual Machine (JVM) and the .NET platform from Microsoft.

Existing Libraries

Scala can thus integrate a large number of already existing libraries and frameworks. As advantages of Scala are called apart from the scalability of the language, their compact code in the comparison to languages such as Java or C-Sharp (C#). From it a clearly higher productivity with the production of software can be derived in the consequence.

Scala is a platform-independent open source software, which is available at present in the version 2, which is to follow then in the year 2010 a revised version. As development environment plug-ins for Eclipse, Netbeans and IntelliJ IDEA are available.

Due to the orientation regarding functional as well as object-oriented concepts, Scala is subject to the influence of several programming languages such as Java, Haskel, Smalltalk, Erlang and ML. The main difference to these languages is that Scala is an extensible, scalable language. The original relatively lean language core can be extended by individual libraries, which then integrate into the language concept. For this purpose, Scala provides appropriately expressive language resources.

Scala connects the function-oriented view of functional programming with the data-oriented view in imperative programming languages such as Java to a closed concept.

Functions are in Scala full-fledged language elements. Here, in addition to closures, the partial evaluation of functions is also provided. Because of the functional approach Scala realizes the creation of software free of side effects. Thereby variables, constants, collection classes and pattern matching are parts of the implementation of this approach in Scala. Likewise Scala optimizes recursive functions.

Object-oriented concept

A further goal of Scala is it to represent object-oriented concepts as compactly, simply usable and consistently as possible. Thereby everything – explicitly also numbers – is an object. Components of Scala are in contrast to Java classes, modules and so-called traits. While the class concept is similar to Java except for the missing static methods or variables and the simplified concept of the so-called “Case Class”, Scala modules are comparable to the design pattern Singleton, after which the module concept is also called Singleton Object. Another new feature of Scala compared to Java are traits, which describes an integrated construct of grouped functionalities (similar to mixins).

Scala provides for the explicit specification of types for variables, parameters, etc., and is thus a strongly typed – or type-safe – programming language. Unless the type of a variable is explicitly specified, Scala assumes the type of the value with which the variable is initialized, which is also called type inference.

Already with the standard library of Scala an interesting concept for parallel programming is provided. This resembles strongly the approach of the actors carried by the programming language Erlang. Here messages are exchanged between different actors, which can process these then in the order of the arrival in parallel. In addition the concept of Scala does not provide for any further expenditures for synchronization.

The Scala distribution already contains an interpreter, with which one can interactively become acquainted with individual language elements. There are however also Plug-Ins for well-known development environments such as Eclipse and NetBeans.

The Java Virtual Machine (JVM) and the .NET platform provide the mechanisms for executing Java code. Java relies on the use of established libraries and frameworks. The volume of Scala code compared to corresponding Java code is significantly lower; in this context one speaks of factors around the values two to three. That saves not only expenditure but provides at the same time for a safe code. In addition in Scala however the possibility is intended to write more complex program parts for the better understanding also in more detailed code. Lift provides a framework for the creation of modern applications for the Internet.