About this Book

If I were to pick a language to use today other than Java, it would be Scala.

JAMES GOSLING

Congratulations for picking Scala as your next language. And if you are still undecided, please read the first chapter in this book, and I am sure that will change your mind.

The programming languages we use shape the way we think and how we solve programming issues. And when faced with new programming languages and paradigms we try to map them to the languages we know. I would discourage you from doing that when reading Scala in Action. Scala is a new programming language that brings myriad new ideas to the Java virtual machine platform.

Scala is unique. It is a multi-paradigm programming language that combines both functional and object-oriented languages. It has its own set of best practices and idioms and by the end of this book what you have learned will also be helpful in other programming languages.

Scala in Action has been updated to reflect the newest changes in Scala version 2.10.

Who should read this book?

This book is for all developers and hobbyists who like programming. Most of the concepts discussed can be easily absorbed without any knowledge of Java, but having a basic knowledge of Java is a definite plus. The book assumes that you are at least familiar with the JVM and its ecosystem. There are plenty of available resources for the JVM and its toolset that augment this book.

Roadmap

This book is divided into three parts. Part 1 introduces the language and its features. Part 2 makes use of the concepts and shows how to use them in real world. Part 3, updated to reflect the introduction of Scala 2.10, continues with real-world examples of building large-scale applications using Java and Akka.

It is recommended that you read the book from beginning to end. Having said that, if some chapters interest you more than others, feel free to jump ahead, but make certain you are familiar with the concepts introduced in the first five chapters (part 1). Chapter 6 is also important because it introduces the build tool used to compile and build the accompanying code samples.

When reading this book, and working with its examples, I recommend that you keep the Scala interpreter (REPL) open at all times. This is a programming book so keep programming as you read.

Part 1: Introducing Scala

Part 1 introduces Scala and the programming paradigms it supports.

Chapter 1 explores why Scala should be your next programming language. The chapter explores features of the language and compares them to other popular programming languages on the market. Picking up and learning a new language is a lot of work and you should read this chapter to understand what Scala has to offer and why Scala should be your next programming language.

Chapter 2 introduces basic Scala features you need to get started with the language. This chapter also introduces one of the most important Scala tools, the Scala REPL. If you have never used the REPL, this chapter will prepare you.

Chapter 3 explores the object-oriented programming side of things in Scala. It introduces traits, case classes, and companion objects, all new innovations in OOP.

Chapter 4 focuses on the Scala collection library, one of the most powerful features of Scala. The collection is one of the things that attracted me to this language. This chapter will introduce new concepts gently so that you can start using Scala collection classes as soon as possible. I promise once you get used to them there is no going back.

Chapter 5 introduces functional programming. This is the logical extension of the previous chapter. This chapter introduces what and why functional programming is important to learn. Even if you don’t use Scala in your projects, some of the concepts introduced here can be used in any programming language.

Part 2: Working with Scala

Chapter 6 takes the first stab at building a large web application using Scala. This chapter will show you how to build and organize a Scala project and it introduces the popular Simple Build Tool (SBT).

Chapter 7, a continuation of the previous chapter, introduces Scala frameworks you can use to connect to the database.

Chapter 8 is about Scala’s type system. No Scala book could be complete without exploration of Scala’s type system. But it’s no fun to talk about types unless you learn their value in design applications in the real world. This chapter introduces types available in Scala and how you can use them to build reusable components.

Chapter 9, extensively reworked after the release of Scala 2.10, introduces actors, one of the most popular aspects of Scala. An actor is a high-level abstraction over threads, allowing you to build and design concurrent applications.

Chapter 10 focuses on testing Scala applications and how you can use patterns to make your code more testable. If you are thinking of taking your Scala application to production you need to learn to write automated tests and to understand dependency injections.

Part 3: Advanced steps

Chapter 11 demonstrates integration with Java, one of the core features of Scala. Using Scala doesn’t necessarily mean you have to use only Scala frameworks. In this chapter you will take Java frameworks like Spring, Hibernate, and Maven and use them with Scala

Chapter 12, also reworked after the release of Scala 2.10, introduces Akka, the most popular framework written in Scala. At the end of the chapter you will build a large distributed and scalable application using Akka. If you are interested in concurrent and parallel programming, this chapter is for you.

Code convention and downloads

This book contains numerous code examples. All the code is in a fixed-width font like this to separate it from ordinary text. Code members such as method names, class names, and so on are also in a fixed-width font.

Source code examples in this book are fairly close to the samples that you’ll find online, but for the sake of brevity, we may have removed material such as comments from the code to fit it well within the text.

Code annotations accompany many of the source code listings, highlighting important concepts. In some cases, numbered bullets link to explanations that follow the listing.

The source code for the examples in the book is available for download from the publisher’s website at www.manning.com/ScalainAction. To run the samples, you’ll need to download some of the tools and languages used in this book. Links in the text point you to places where you can get the relevant files.

Software requirements

You can use any platform of your choice as long as you have a Java runtime version 1.5 or later running. I have used Java 6 on Mac OS X for running and building all the code examples.

Author Online forum

The purchase of Scala in Action includes free access to a private web forum run by Manning Publications, where you can make comments about the book, ask technical questions, and receive help from the author and from other users. To access the forum and subscribe to it, point your web browser at www.manning.com/ScalainAction. This page provides information on how to get on the forum once you are registered, what kind of help is available, and the rules of conduct on the forum.

Manning’s commitment to our readers is to provide a venue where a meaningful dialogue between individual readers and between readers and authors can take place. It’s not a commitment to any specific amount of participation on the part of the author, whose contribution to the forum remains voluntary (and unpaid). We suggest you try asking the author some challenging questions, lest his interest stray! The Author Online forum and archives of previous discussions will be accessible from the publisher’s website as long as the book is in print.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset