Book Image

Professional Scala

By : Mads Hartmann, Ruslan Shevchenko
Book Image

Professional Scala

By: Mads Hartmann, Ruslan Shevchenko

Overview of this book

This book teaches you how to build and contribute to Scala programs, recognizing common patterns and techniques used with the language. You’ll learn how to write concise, functional code with Scala. After an introduction to core concepts, syntax, and writing example applications with scalac, you’ll learn about the Scala Collections API and how the language handles type safety via static types out-of-the-box. You’ll then learn about advanced functional programming patterns, and how you can write your own Domain Specific Languages (DSLs). By the end of the book, you’ll be equipped with the skills you need to successfully build smart, efficient applications in Scala that can be compiled to the JVM.
Table of Contents (12 chapters)

Chapter 1. Setting up the Development Environment

Before we start writing the various programs in this book, let's talk a little about the Scala language itself. Why is it necessary, and what has made Scala unique? What are the most important aspects of the language?

Scala was created in 2001 in EPFL (École Polytechnique Fédérale de Lausanne), by Martin Odersky. This is the same lab where Pascal language (widely used up to the end of the 1990s) was created.

Scala is an abbreviation for 'Scalable Language'—a language which can be scaled, that is, it allows you to write complex systems with gigantic amounts of functionality. As specified on Scala's home page: " Scala combines object-oriented and functional programming in one concise, high-level language."

Note

You can visit Scala's official home page here: https://www.scala-lang.org/

By the end of this chapter, you will be able to:

  • Recognize the structure of a Scala project

  • Identify the use of Scala's sbt tool (interactive build tool) for building and running your project

  • Identify how to use the IDE

  • Implement interactions with a simple chatbot

Scala is built on top of the JVM platform (the Scala program is compiled to use JVM bytecode).

Now, the language is used as one of the most preferred platforms in many areas, such as high-load soft-realtime applications, ad servers for data science toolkits.

Some characteristics of Scala are as follows:

  • An advanced type system, which makes Scala superior (but at the same time, more complex) compared to most other industrial programming languages.

  • Static typing, which allows you to write code in a safe way when errors are checked during compilation.

In this chapter, we will learn the basics of Scala, such as what the simple Scala program looks like and what a typical developer flow is. A significant part of development is interaction with tools—build tools, dependency extractors, IDEs, and so on, which form the tool ecosystem with the language. We will build a simple program using mainstream tools.