Book Image

Learn Scala Programming

By : Slava Schmidt
Book Image

Learn Scala Programming

By: Slava Schmidt

Overview of this book

The second version of Scala has undergone multiple changes to support features and library implementations. Scala 2.13, with its main focus on modularizing the standard library and simplifying collections, brings with it a host of updates. Learn Scala Programming addresses both technical and architectural changes to the redesigned standard library and collections, along with covering in-depth type systems and first-level support for functions. You will discover how to leverage implicits as a primary mechanism for building type classes and look at different ways to test Scala code. You will also learn about abstract building blocks used in functional programming, giving you sufficient understanding to pick and use any existing functional programming library out there. In the concluding chapters, you will explore reactive programming by covering the Akka framework and reactive streams. By the end of this book, you will have built microservices and learned to implement them with the Scala and Lagom framework.
Table of Contents (19 chapters)

Summary

Traditional streaming solutions suffer from one of two issues. In the case of pulling, there is a need for locking or extensive use of resources on the side of the quick consumer. In the case of pushing, there is a possibility that a number of messages to process will grow bigger than the available memory, requiring a slow consumer to drop messages or terminate because of the memory overflow. Reactive Streams solves this problem by defining dynamic asynchronous pull-push with back pressure. Akka Streams implements the Reactive Streams standard using Akka which allows for seamless integration with both technologies.

Streams in Akka are built from blocks called stages or flows. These blocks can be nested and connected to each other, forming graphs. Graphs with single input and single output can be made runnable by connecting them to the source and sink. Graph definitions...