Get Programming with Scala
Daniela Sfregola
  • MEAP began December 2017
  • Publication in Early 2021 (estimated)
  • 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.

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.
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: List

Lesson 27: List

27.1 Creating a List

27.2 Adding elements to a List

27.3 Pattern matching on a List

27.4 Summary

27.5 Answers to Quick Checks

Lesson 28: Working with List: map and flatMap

28.1 The map, flatten, and flatMap operations

28.1.1 The map function

28.1.2 The flatten function

28.1.3 The flatMap function

28.2 For-comprehension

28.3 Summary

28.4 Answers to Quick Checks

Lesson 29: Working with List: properties

29.1 Size of a List

29.2 Properties of the elements in a list

29.3 Summary

29.4 Answers to Quick Checks

Lesson 30: Working with List: element selection

30.1 Selecting an element by its position

30.2 Finding an element with given features

30.3 Picking the minimum or maximum item

30.4 Summary

30.5 Answers to Quick Checks

Lesson 31: Working with List: filtering

31.1 Dropping and Taking elements

31.2 Filtering Items of a List

31.3 Removing duplicates

31.4 Summary

31.5 Answers to Quick Checks

Lesson 32: Working with List: sorting and other operations

32.1 Sorting elements

32.2 Converting a List to a String

32.3 Sum elements of numerical sequences

32.4 Grouping elements by feature

32.5 Summary

32.6 Answers to Quick Checks

Lesson 33: CAPSTONE 5: The Movies Dataset

33.1 Download the base project

33.2 Parsing a Movie entity

33.3 Printing Query Results

33.4 Querying the Movie Dataset

33.5 Summary

Unit 6: ERROR HANDLING AND DATA STORAGE

Lesson 34: Set

34.1 Creating a Set

34.2 Adding and removing elements

34.3 The map, flatten, and flatMap operations

34.3.1 The map function

34.3.2 The flatten function

34.3.3 The flatMap function

34.4 For-comprehension

34.5 Summary

Lesson 35: Working with Set

35.1 The Union, Intersection, Difference Operations

35.2 Other Operations on Set

35.3 Summary

35.4 Answers to Quick Checks

Lesson 36: Map

36.1 Creating a Map

36.2 Adding and Removing elements

36.3 Merge and remove multiple entries

36.4 The map and flatMap operations

36.4.1 The map function

36.4.2 The flatMap function

36.5 For-comprehension

36.6 Summary

36.7 Answers to Quick Checks

Lesson 37: Working with map

37.1 Retrieving a value for a given key

37.2 Getting all keys and values

37.3 Other Operations on Map

37.4 Summary

37.5 Answers to Quick Checks

Lesson 38: Either

38.1 Why Either?

38.2 Creating an Either

38.3 Pattern Matching on Either

38.4 The map and flatMap operations

38.4.1 The map function

38.4.2 The flatMap function

38.5 For-comprehension

38.6 Summary

38.7 Answers to Quick Checks

Lesson 39: Working with Either

39.1 Retrieving an Either value

39.2 Properties of an Either value

39.3 Summary

39.4 Answers to Quick Checks

Lesson 40: Error Handling with Try

40.1 Creating a Try

40.2 Pattern Matching on Try

40.3 The map, flatten, and flatMap operations

40.3.1 The map function

40.3.2 The flatten function

40.3.3 The flatMap function

40.4 For-comprehension

40.5 Other operation on Try

40.6 Summary

40.7 Answers to Quick Checks

Lesson 41: The Library Application

41.1 Download the base project

41.2 Parsing a Book Entity

41.3 The Business Logic Layer

41.3.2 Reserving a book

41.3.3 Returning a book

41.4 Let’s give it a try!

41.5 The ugly bits of our solution

41.6 Summary

Unit 7: Concurrency

Lesson 42: Implicit functions and values

Lesson 43: Future

Lesson 44: Working with Future: map and flatMap

Lesson 45: Working with Future: for-comprehension

Lesson 46: Database queries with quill

Lesson 47: CAPSTONE 7

Unit 8: JSON (de)serialization

Lesson 48: JSON (De)serialization with circe

Lesson 49: Lazy values

Lesson 50: By Name Parameters

Lesson 51: The IO type

Lesson 52: Capstone 8

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 https://danielasfregola.com/.

placing your order...

Don't refresh or navigate away from the page.
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.
print book $34.99 $49.99 pBook + eBook + liveBook
Additional shipping charges may apply
Get Programming with Scala (print book) added to cart
continue shopping
go to cart

eBook $27.99 $39.99 3 formats + liveBook
Get Programming with Scala (eBook) added to cart
continue shopping
go to cart

Prices displayed in rupees will be charged in USD when you check out.

FREE domestic shipping on three or more pBooks