Get Programming with Scala
Daniela Sfregola
  • MEAP began December 2017
  • Publication in April 2019 (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.
Table of Contents detailed table of contents

Unit 0: Hello Scala!

Lesson 1: Why Scala?

1.1 Scala and the JVM

1.2 Scala’s key features

1.3 Advantages of adopting Scala

1.4 Summary

Lesson 2: Scala — The REPL

2.1 The REPL Commands

2.2 The REPL Code Evaluation

2.3 Summary

Lesson 3: SBT — Scala Build Tool

3.1 SBT Commands

3.2 Your first SBT Project

3.3 SBT Project Structure

3.4 Summary

Unit 1: Statements, Expressions, and Values

Lesson 4: Values and Variables

4.1 Values

4.2 Variables

4.3 Lazy Values

4.4 Summary

4.5 Answers to quick checks

Lesson 5: Conditional Statements

5.1 If…​else statement

5.2 Pattern matching

5.3 Summary

5.4 Answers to quick checks

Lesson 6: Import and Packages

6.1 Import an existing Package

6.2 Create a Package

6.3 Create a Package Object

6.4 Summary

6.5 Answers to Quick Checks

Lesson 7: Access Modifiers

7.1 Default Access Modifier

7.2 Private

7.3 Protected

7.4 Package private

7.5 Which Access Modifier to use?

7.6 Summary

7.7 Answers to Quick Checks

Lesson 8: Let’s build a vending machine!

8.1 The Vending Machine: customer flow

8.1.1 The VendingMachine class and its APIs

8.1.2 The Vending Machine and its operations

8.2 The Vending Machine: operator flow

8.2.1 The Operator class and its APIs

8.2.2 The Operator: collecting Money and adding products

8.2.3 Let’s try it out

8.3 The ugly bits of our solution

8.4 Summary

Unit 2: Structure your Code

Lesson 9: Classes and Subclasses to represent the world

9.1 Class

9.2 Subclass

9.3 Abstract class

9.4 Anonymous Class

9.5 Summary

9.6 Answers to Quick Checks

Lesson 10: Objects are important too!

10.1 Object

10.1.1 Object as executable program

10.2 Companion Object

10.2.1 The Apply Method

10.3 Summary

10.4 Answers to Quick Checks

Lesson 11: Traits as composable blocks of code

11.1 Fragments of code on steroids

11.2 Trait versus Abstract Class

11.3 Seal traits

11.4 Summary

11.5 Answers to Quick Checks

Lesson 12: Case Classes to structure your data

12.1 Case class

12.2 Case object

12.3 Tuples

12.4 Summary

12.5 Answers to Quick Checks

Lesson 13: Rock, Paper, Scissors, Lizard, Spock!

13.1 Implementing Rock, Paper, Scissor, Lizard, Spock!

13.1.1 What’s a symbol?

13.1.2 Defining each symbol

13.1.3 The Game representation

13.1.4 Let’s give it a try

13.2 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

Lesson 19: Case classes to structure our data

Lesson 20: High Order Functions

Lesson 21: What is Purity?

Lesson 22: Purity versus Impurity

Lesson 23: Option

Lesson 24: Working with Option: map and flatMap

Lesson 25: Working with Option: for-comprehension

Lesson 26: Tuple and Unapply

Lesson 27: Capstone 4

Unit 5: Collections and json (de)serialization

Lesson 28: Infix and Postfix Notation

Lesson 29: List

Lesson 30: Working with List

Lesson 31: Map

Lesson 32: Traits as composable block of codes

Lesson 33: Lazy values

Lesson 34: Implicit functions and values

Lesson 35: The IO type

Lesson 36: JSON (De)serialization with circe

Lesson 37: Capstone 5

Unit 6: Error handling and data storage

Lesson 38: Either

Lesson 39: Try: an operation that can fail

Lesson 40: Working with Try

Lesson 41: Database queries with quill

Lesson 42: Capstone 6

Unit 7: Concurrency

Lesson 43: Future

Lesson 44: Working with Future: map and flatMap

Lesson 45: Working with Future: for-comprehension

Lesson 46: Future and Promise

Lesson 47: Capstone 7

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

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

placing your order...

Don't refresh or navigate away from the page.

FREE domestic shipping on three or more pBooks

Lots of code snippets and examples make it easy to learn a language that has a reputation of being difficult.

William E. Wheeler

If you know nothing about Scala and you want to learn it, this is your book.

Emanuele Origgi