Get Programming with Scala
Daniela Sfregola
  • ISBN 9781617295270
  • 475 pages (estimated)
  • printed in black & white

Explains the basics of the language in a very simple and captivating way.

Davide Cadamuro
Scala is a multi-style programming language for the JVM that supports both object-oriented and functional programming. Master Scala, and you'll be well-equipped to match your programming approach to the type of problem you're dealing with. Packed with examples and exercises, Get Programming with Scala is perfect starting point for developers with some OO knowledge who want to learn Scala and pick up a few FP skills along the way.
Table of Contents detailed table of contents

Unit 0: Hello Scala!

Lesson 1 Why Scala?

1.1 Why Scala?

1.2 Scala and the JVM

1.3 Scala’s key features

1.4 Summary

Lesson 2 Scala — The REPL

2.1 The REPL Installation

2.2 The REPL Commands

2.3 The REPL Code Evaluation

2.4 Summary

Lesson 3 SBT — Scala Build Tool

3.1 Why SBT?

3.2 SBT Installation

3.3 SBT Commands

3.4 Your first SBT Project

3.5 SBT Project Structure

3.6 Summary

Unit 1: The Basics

Lesson 4 Values and Variables

4.1 Values

4.2 Variables

4.3 Summary

4.4 Answers to quick checks

Lesson 5 Conditional Statements and Loops

5.1 If…​else statement

5.2 While Loop

5.3 For Loop

5.4 Summary

5.5 Answers to quick checks

Lesson 6 Function as the most fundamental block of code

6.1 Functions

6.2 Summary

6.3 Answers to Quick Checks

Lesson 7 Classes and Subclasses to represent the world

7.1 Class

7.2 Subclass

7.3 Abstract class

7.4 Summary

7.5 Answers to Quick Checks

Lesson 8 Capstone 1: Let’s build a vending machine!

8.1 The Vending Machine

8.1.1 The VendingMachine class and its APIs

8.1.2 The Vending Machine and its operations

8.1.3 Let’s try it out

8.2 The ugly bits of our solution

8.3 Summary

Unit 2: Object-Oriented Fundamentals

Lesson 9 Import and Create Packages

9.1 Import an existing Package

9.2 Create a Package

9.3 Summary

9.4 Answers to Quick Checks

Lesson 10 Scope your code with Access Modifiers

10.1 Public, the Default Access Modifier

10.2 Private

10.3 Protected

10.4 Which Access Modifier to use?

10.5 Summary

10.6 Answers to Quick Checks

Lesson 11 Singleton Objects

11.1 Object

11.1.1 Executable Object

11.2 Companion Object

11.2.1 The Apply Method

11.3 Summary

11.4 Answers to Quick Checks

Lesson 12 Traits as interfaces

12.1 Defining traits

12.2 Extending traits

12.3 Seal traits

12.4 Summary

12.5 Answers to Quick Checks

Lesson 13 Capstone 2: What time is it?

13.1 What time is it?

13.1.1 SBT Project Setup

13.1.2 The Business Logic Layer

13.1.3 The HTTP server

13.1.4 Let’s try it out!

13.2 The ugly bits of our solution

13.3 Summary

Unit 3: HTTP Server

Lesson 14 Pattern Matching

14.1 If…​else Statement versus Pattern Matching

14.2 Sealed Pattern Matching

14.3 Summary

14.4 Answers to quick checks

Lesson 15 Anonymous Functions

15.1 Function versus Anonymous Function

15.2 Concise notation for Anonymous Functions

15.3 Summary

15.4 Answers to Quick Checks

Lesson 16 Partial Functions

16.1 Partial Functions

16.1.1 Implementing a Partial Function

16.1.2 Function composition

16.2 Use case: Exception Handling

16.3 Summary

16.4 Answers to Quick Checks

Lesson 17 HTTP API with http4s

17.1 An overview of http4s

17.2 A Ping Server using http4s

17.2.1 Initial Setup

17.2.2 Implementing an HttpService

17.2.3 Building a StreamApp

17.2.4 Let’s try it out!

17.3 Summary

17.4 Answers to Quick Checks

Lesson 18 Capstone 3: The Time HTTP Server

18.1 What time is it?

18.1.1 SBT Project Setup

18.1.2 The TimePrinter class

18.1.3 The API Routes

18.1.4 The HTTP server

18.1.5 Let’s try it out!

18.2 The ugly bits of our solution

18.3 Summary

Unit 4: Immutable Data and Structures

Lesson 19 Case Classes to structure your data

19.1 Case class

19.2 Pattern Matching and Case Classes

19.3 Case object

19.4 Summary

19.5 Answers to Quick Checks

Lesson 20 High Order Functions

20.1 Functions as Parameters

20.2 Functions as return values

20.3 Summary

20.4 Answers to Quick Checks

Lesson 21 What is Purity?

21.1 A definition of Purity

21.2 Differentiating between pure and impure functions

21.3 Summary

21.4 Answers to Quick Checks

Lesson 22 Option

22.1 Why Option?

22.2 Creating an Option

22.3 Pattern Matching on Option

22.4 Summary

22.5 Answers to Quick Checks

Lesson 23 Working with Option: map and flatMap

23.1 Transforming an Option

23.1.1 The map function

23.1.2 The flatten function

23.1.3 The flatMap function

23.2 Summary

23.3 Answers to Quick Checks

Lesson 24 Working with Option: for-comprehension

24.1 For-comprehension on Option

24.1.1 For-comprehension as syntactic sugar for nested map and flatMap calls

24.1.2 Filtering values within For-Comprehension

24.2 Other operations on Option

24.3 Summary

24.4 Answers to Quick Checks

Lesson 25 Tuple and Unapply

25.1 Tuples

25.2 Implementing the Unapply Method

25.3 Summary

25.4 Answers to Quick Checks

Lesson 26 Capstone 4: Rock, Paper, Scissors, Lizard, Spock!

26.1 Implementing Rock, Paper, Scissors, Lizard, Spock!

26.1.1 SBT Project Setup and Packages

26.1.2 Defining a Symbol

26.1.3 Representing a Player

26.1.4 Defining a Game

26.1.5 The API Routes

26.1.6 The HTTP Server

26.1.7 Let’s try it out!

26.2 The ugly bits of our solution

26.3 Summary

Unit 5: Collections

Lesson 27: List

Lesson 28: Working with List

Lesson 29: Set

Lesson 30: Map

Lesson 31: Testing with ScalaTest

Lesson 32: Capstone 5

Unit 6: Error handling and data storage

Lesson 33: Either

Lesson 34: Try: an operation that can fail

Lesson 35: Working with Try

Lesson 36: Database queries with quill

Lesson 37: Capstone 6

Unit 7: Concurrency

Lesson 38: Future

Lesson 39: Working with Future: map and flatMap

Lesson 40: Working with Future: for-comprehension

Lesson 41: Future and Promise

Lesson 42: Capstone 7

Unit 8: JSON (de)serialization

Lesson 43: Traits as composable block of codes

Lesson 44: Lazy values

Lesson 45: By Name Parameters

Lesson 46: Implicit functions and values

Lesson 47: The IO type

Lesson 48: JSON (De)serialization with circe

Lesson 49: Capstone 8

About the Technology

Although it’s a relative newcomer, Scala turned out to be the right language at the right time, opening up the world of functional programming to the JVM. Scala looks a lot like Java, and it interacts seamlessly with familiar Java libraries and tools. Since it fully supports functional programming, Scala gives you the freedom to choose the right programming style exactly when it benefits you. Scala can be daunting at first, especially if you’re seeing FP ideas for the first time. Fortunately, with the examples and exercises in this book, you’ll get over the initial learning hump quickly and start doing interesting projects before you know it!

About the book

Get Programming with Scala teaches you the core skills you'll need to code with Scala. This book lives up to its name! You'll learn the ins and outs of Scala by actually programming with it, thanks to the practical examples, exercises, and easy-to-follow lessons. You'll start by reviewing OOP concepts in the Scala language. Then, example-by-example, you'll gradually open up the world of functional programming. You'll explore functions and types and learn how to combine them to create powerful, flexible abstractions. Along the way, you'll learn some Scala testing and get an intuition for sniffing out and fixing code that doesn't smell quite right.

What's inside

  • Learn to express OO principles in Scala
  • Express your program designs in functions
  • Make use of types to enforce program requirements
  • Use abstractions to avoid code duplication
  • Write meaningful tests and recognize code smells

About the reader

Written for developers with some prior experience in an OOP language like Java or C#. No experience with Scala or functional programming is needed.

About the author

Daniela Sfregola started working with Scala in 2013. Since then she has been an active contributor to the Scala Community. Daniela currently maintains several open source projects in the community and regularly speaks at Scala conferences. She blogs about Scala regularly at

Manning Early Access Program (MEAP) Read chapters as they are written, get the finished eBook as soon as it’s ready, and receive the pBook long before it's in bookstores.
MEAP combo $49.99 pBook + eBook + liveBook
MEAP eBook $39.99 pdf + ePub + kindle + liveBook
Prices displayed in rupees will be charged in USD when you check out.

placing your order...

Don't refresh or navigate away from the page.

FREE domestic shipping on three or more pBooks