Desktop version

Home arrow Computer Science arrow Building Applications with Scala



Functional programming started in academia and ended up in the IT industry. The Scala language is a multi-paradigm language used by big players and large organizations that helps you get the correct (in the sense of pure functional programming) software and, at the same time, software that is practical and scalable.

Scala has a very rich ecosystem, including Play Framework, Akka, Slick, Gatling, Finable, and more. In this book, we will start right from the basic principles and ideas on functional and ReactiveX programming, and through practical examples, you will learn how to code with the most important frameworks of the Scala ecosystem, such as Play, Akka, and Slick.

You will learn how to bootstrap a Scala application with SBT and Activator, how to build a Play and Akka application step by step, and we cover the theory of how to scale massive Scala applications with cloud and the NetflixOSS stack. This book will help you to go from the basic subjects to the most advanced ones in order to make you a Scala expert.

What this book covers

chapter 1, Introduction to FP, Reactive, and Scala, looks at how to set up a Scala development environment, the difference between functional programming and object-oriented programming, and the concepts of functional programming.

chapter 2, Creating Your App Architecture and Bootstrapping with SBT, discusses the overall architecture, SBT basics, and how to create your own application.

chapter 3, Developing the UI with Play Framework, covers the principles of web development in Scala, creating our models, creating our views, and adding validations.

chapter 4, Developing Reactive Backing Services, introduces you to reactive programming principles, refactoring our controllers, and adding Rx Scala to our services.

chapter 5, Testing Your Application, looks into testing principles with Scala and JUnit, behavior-driven development principles, using ScalaTest specs and DSL in our tests, and running our tests with SBT.

chapter 6, Persistence with Slick, covers principles of database persistence with Slick, working with Functional Relational Mapping in your application, creating the queries you need with SQL support, and improving the code with async database operations.

chapter 7, Creating Reports, helps you understand Jasper reports and add database reports to your application.

chapter 8, Developing a Chat with Akka, discusses the actor model, actor systems, actor routing, and dispatchers.

chapter 9, Design Your REST API, looks into REST and API design, creating our API with REST and JSON, adding validations, adding backpressure, and creating a Scala client.

chapter 10, Scaling Up, touches upon the architecture principles and scaling up the UI, reactive drivers, and discoverability. It also covers middle-tier load balancers, timeouts, back pressure, and caching, and guides you through scaling up microservices with an Akka cluster and scaling up the infrastructure with Docker and AWS cloud.

What you need for this book

For this book, you will need the following:

  • • Ubuntu Linux 14 or superior
  • • Java 8 update 48 or superior Scala 2.11.7
  • • Typesafe Activator 1.3.9
  • • Jasper Reports Designer
  • • Windows fonts for Linux
  • • Eclipse IDE

Who this book is for

This book is for professionals who want learn Scala, as well as functional and reactive techniques. This book is mainly focused on software developers, engineers, and architects. This is a practical book with practical code; however, we also have theory about functional and reactive programming.


In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "The next step is to create the environment variable called scala_home, and to put the Scala binaries in the path variable."

A block of code is set as follows:

package scalabook.javacode.chapl;

public class HelloWorld {

public static void main(String args[]){

System.out.println("Hellow World");



Any command-line input or output is written as follows:

export JAVA_HOME=~/jdk1.8.0_77 export PATH=$PATH:$JAVA_HOME/bin

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "The Actor behavior is the code you will have inside your Actor."

Warnings or important notes appear in a box like this.

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book--what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail This email address is being protected from spam bots, you need Javascript enabled to view it , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from your account at http ://www. p acktpub. com. If you purchased this book elsewhere, you can visit http ://www. packtpub. c om/supportand register to have the files e-mailed directly to you.

You can download the code files by following these steps:

  • 1. Log in or register to our website using your e-mail address and password.
  • 2. Hover the mouse pointer on the SUPPORT tab at the top.
  • 3. Click on Code Downloads & Errata.
  • 4. Enter the name of the book in the Search box.
  • 5. Select the book for which you're looking to download the code files.
  • 6. Choose from the drop-down menu where you purchased this book from.
  • 7. Click on Code Download.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • • WinRAR / 7-Zip for Windows
  • • Zipeg / iZip / UnRarX for Mac
  • • 7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https ://github. com/PacktPubi ishing/Building-Applications-with-scaia. We also have other code bundles from our rich catalog of books and videos available at https ://github. com/PacktPubiishing/. Check them out!

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www . packtpub . com/sites/default/f iles/down loads/BuildingApplicationswithScala_ColorImages.pdf.


Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books--maybe a mistake in the text or the code-- we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http ://www. packtpub. com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https ://www. packtpub. com/books/conten t/supportand enter the name of the book in the search field. The required information will appear under the Errata section.


Found a mistake? Please highlight the word and press Shift + Enter  
< Prev   CONTENTS   Next >