Scala is a modern, object-functional, multi-paradigm, Java-based programming and scripting language that’s released under the BSD 3-Clause License. It blends functional and object-oriented programming models. Scala introduces several innovative language constructs. It improves on Java’s support for object-oriented programming by traits, which are stackable and cannot have constructor parameters. It also offers closures, a feature that dynamic languages like Python and Ruby have adopted.
Scala is particularly useful for building cloud-based/deliverable Software as a Service (SaaS) online applications, and is also proficient to develop traditional, imperative code.
The language helps programmers write tighter code. It uses a number of techniques to cut down on unnecessary syntax, which helps to make code succinct. Typically, code sizes are reduced by an order of 2 or 3 compared to an equivalent Java application.
We publish a series covering the best open source programming books for other popular languages. Read them here.
By Dean Wampler, Alex Payne (450 pages)
Programming Scala introduces a language that offers all the benefits of a modern object model, functional programming, and an advanced type system. This book teaches the reader how to be productive with this language quickly, and explains what makes this language ideal for today’s highly scalable, component-based applications that support concurrency and distribution.
- Zero to Sixty: Introducing Scala
- Type Less, Do More – discusses uses of Scala that promote succinct, flexible code
- Rounding Out the Essentials
- Basic Object-Oriented Programming in Scala
- Advanced Object-Oriented Programming In Scala
- The Scala Object System
- Functional Programming in Scala
- Robust, Scalable Concurrency with Actors
- Herding XML in Scala
- Domain-Specific Languages in Scala
- The Scala Type System
- Application Design
- Scala Tools, Libraries and IDE Support
The book was part of the O’Reilly Media Open Feedback Publishing System. This work has been released under the Creative Commons Attribution-Noncommercial license.
By Martin Odersky, Lex Spoon, and Bill Venners (754 pages)
Programming in Scala is a comprehensive step-by-step tutorial, written by people directly involved in the development of the language. It’s a comprehensive tutorial and reference; the book covers the entire language and important libraries.
- A Scalable Language
- First Steps in Scala – learn some Scala basics
- Next Steps in Scala – introduces some more advanced features including lists, tuples, sets and maps
- Classes and Objects – takes a deeper look at classes and objects with an overview of semicolon inference
- Basic Types and Operations – looks at Scala’s basic types and operations in more depth. It provides an overview of Scala’s basic types, including Strings and the value types Int, Long, Short, Byte, Float, Double, Char, and Boolean. Learn the operations that can be performed on these types, including how operator precedence works in Scala expressions
- Functional Objects – classes that define functional objects, that is, objects that do not have any mutable state
- Built-in Control Structures – Scala has only a handful of built-in control structures
- Functions and Closures – looks at methods, local functions, first-class functions, short forms of function literals, placeholder syntax, partially applied functions, closures, repeated parameters, and tail recursion
- Control Abstraction – shows the reader how to apply function values to create new control abstractions
- Composition and Inheritance – explores with much greater detail into Scala’s support for object-oriented programming
- Scala’s Hierarchy – looks at Scala’s class hierarchy as a whole
- Traits – shows the reader how traits work and shows two of the most common ways they are useful: widening thin interfaces to rich ones, and defining stackable modifications
- Packages and Imports – shows several constructs that help you program in a modular style
- Assertions and Unit Testing – shows the reader several options to write and run assertions and unit tests
- Case Classes and Pattern Matching – particularly helpful for tree-like recursive data
- Working with Lists – explains lists in detail. It presents many common operations that can be performed on lists. It also teaches some important design principles for programs working on lists
- Collections – provides an overview of how collection types relate to each other in the collections inheritance hierarchy
- Stateful Objects – explains what stateful objects are, and what Scala provides in terms of syntax to express them. The second part of this chapter introduces a larger case study on discrete event simulation, which involves stateful objects as well as building an internal domain specific language (DSL) for defining digital circuits to simulate
- Type Parameterization – explains the details of type parameterization in Scala
- Abstract Members – describes all four kinds of abstract member: vals, vars, methods, and types. The authors also broach pre-initialized fields, lazy vals, path-dependent types, and enumerations
- Implicit Conversions and Parameters – shows the reader how implicits work, and presents some of the most common ways they are used
- Implementing Lists – explains how lists are implemented in Scala
- For Expressions Revisited – details the precise rules of writing for expressions, see how they can make combinatorial problems easier to solve, and how for expressions are translated
- Extractors – explains what extractors are and how you can use them to define patterns that are decoupled from an object’s representation
- Annotations – shows how to use annotations in Scala. It shows their general syntax and how to use several standard annotations
- Working with XML – offers a brief introduction into Scala’s support for XML
- Modular Programming Using Objects – discuss how you can use Scala’s object-oriented features to make a program more modular
- Object Equality – looks at object equality in detail and gives some recommendations to consider when you design your own equality tests
- Combining Scala and Java – discusses how Scala is translated to Java and the use of Java annotations in Scala
- Actors and Concurrency – shows you the basics of how to use Scala’s actors library
- Combinator Parsing – introduces the language feature, aliasing. The chapter also shows how various language elements can be combined in the design of a very high-level library
- GUI Programming – learn how to develop in Scala applications that use a graphical user interface (GUI)
- The SCells Spreadsheet – see how constructs play together in the implementation of a sizable application. The task is to write a spreadsheet application, SCells
The publisher does not explicitly state the license terms of the first edition.
By Noel Welsh, Dave Gurnell (245 pages)
The book teaches you the language from the basics of its syntax to advanced problem solving techniques. It’s aimed at experienced developers who are encountering Scala for the first time.
- Getting Started
- Expressions, Types and Values
- Objects and Classes
- Modelling Data with Traits
- Sequencing Computations
- Type Classes
- Pattern Matching
- Collections Redux
- Solutions to Exercises
It’s published under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
By Dave Gurnell, Noel Welsh (198 pages)
The aim of Creative Scala is to show the reader the building blocks that Scala developers use to create programs.
It’s aimed at developers who have no prior experience in Scala, and designed to give a fun introduction to functional programming.
- Getting Started
- Expressions, Types and Values
- Computing with Pictures
- Writing Larger Programs
- The Substitution Model of Evaluation
- Structural Recursion
- Horticulture and Higher-order Functions
- Shapes, Sequences, and Stars
- Turtle Algebra and Algebraic Data Types
- Composition of Generative Art
- Algebraic Data Types to Call Our Own
- Syntax Quick Reference
- Solutions to Exercises
The exercises in Creative Scala are based on a functional graphics library called Doodle.
It is published under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Note: This book is not finished.
By Dave Gurnell (115 pages)
The book is divided into two parts. Part I introduces the general mechanisms for type class derivation in shapeless. It introduces generic encodings of product and coproduct types (case classes and sealed traits), and shows how to implement type classes by solving problems at the generic level.
Part II opens the shapeless toolbox and show how to apply the solutions from Part I to a wider range of situations. The author introduces polymorphic functions that let us map and flatMap over generic representations, and show how we can count at the type level.
The book is published under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Click to rate this software