About this Book

Scala in Depth is a practical guide to using Scala with deep dives into necessary topics. This book, picking up where introductory books drop off, enables readers to write idiomatic Scala code and understand trade-offs when making use of advanced language features. In particular, this book covers Scala’s implicit and type systems in detail before discussing how these can be used to drastically simplify development. The book promotes the “blended style” of Scala, where paradigms are mixed to achieve something greater.

Who should read this book?

Scala in Depth is for new or intermediate Scala developers who wish to improve their skills with the language. While this book covers very advanced concepts in Scala, it attempts to pull along those new to Scala.

This book was written for readers who know Java or another object-oriented language. Prior experience with Scala is helpful but not required. It covers Scala 2.7.x through Scala 2.9.x.

Roadmap

Scala in Depth begins with a philosophical discussion of the “xen” of Scala—that Scala is a blending of concepts that achieve a greater whole when combined. In particular, three dichotomies are discussed: static typing versus expressiveness, functional programming versus object-oriented programming, and powerful language features versus dead simple Java integration.

Chapter 2 is a discussion of the core rules of Scala. These are the things that every Scala developer should be aware of and make use of in daily development. This chapter is for every Scala developer and covers the basics that make Scala a great language.

Chapter 3 is a digression in code style and associated issues. Scala brings a few new players to the table, and any Scala style guide should reflect that. Some common conventions from popular languages like Ruby and Java can actually be deterrents to good Scala code.

Chapter 4 covers new issues arising in object-oriented design due to Scala’s mixin inheritance. One topic of interest to any Scala developer is the early initializer coverage, which gets little coverage in other books.

After object orientation, the book moves into the implicit system. In chapter 5, rather than simply discussing best practices, a deep dive is taken into the mechanics of implicits in Scala. This chapter is a must for all Scala developers who wish to write expressive libraries and code.

Chapter 6 is devoted to Scala’s type system. The discussion covers all the ways types appear in Scala and how to utilize the type system to enforce constraints. The chapter moves into a discussion of higher-kinded types and finishes with a dive into existential types.

Chapter 7 discusses the most advanced usage patterns in the language, the intersection of types and implicits. This intersection is where a lot of interesting and powerful abstractions occur, the epitome of which is the type class pattern.

Having covered the most advanced aspects of Scala, in chapter 8 we move into a discussion of Scala’s collection library. This includes the design and performance of Scala’s collections as well as how to deal with the powerful type mechanisms.

Chapter 9 kicks off the discussion on actors in Scala. Actors are a concurrency mechanism that can provide great throughput and parallelism when used appropriately. The chapter dives into issues of designing actor-based systems and finishes with a demonstration of how the Akka actors library provides best practices by default.

Chapter 10 covers Java integration with Scala. While Scala is more compatible with Java than most other JVM languages, there’s still a mismatch in features between the two. It’s at these corners that issues arise in Scala-Java integration and this chapter provides a few simple rules that help avoid these issues.

Chapter 11 takes concepts from category theory and makes them practical. In pure functional programming, a lot of concepts from category theory have been applied to code. These are akin to object-oriented design patterns, but far more abstract. While they have terrible names, as is common in mathematics, these concepts are immensely useful in practice. No coverage of functional programming would be complete without a discussion of some of these abstractions, and Scala in Depth does its best to make these concepts real.

Code downloads and conventions

All source code in the book is in a fixed-width font like this, which sets it off from the surrounding text. In many listings, the code is annotated to point out the key concepts. I have tried to format the code so that it fits within the available page space in the book by adding line breaks and using indentation carefully. Sometimes, however, very long lines include line-continuation markers.

Source code for all the working examples is available from www.manning.com/ScalainDepth and at https://github.com/jsuereth/scala-in-depth-source. To run the examples, readers should have Scala installed and, optionally, SBT (http://scalasbt.org).

Code examples appear throughout this book. Longer listings appear under clear listing headers; shorter listings appear between lines of text.

Author online

Purchase of Scala in Depth 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 authors and from other users. To access the forum and subscribe to it, point your web browser to www.manning.com/ScalainDepth. This page provides information on how to get on the forum once you’re 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 dialog between individual readers and between readers and the authors can take place. It’s not a commitment to any specific amount of participation on the part of the authors, whose contribution to the AO forum remains voluntary (and unpaid). We suggest you try asking the author some challenging questions lest his interest stray.

The Author Online forum and the archives of previous discussions will be accessible from the publisher’s website as long as the book is in print.

About the author

Josh Suereth is a Senior Software Engineer at Typesafe Inc., the company behind Scala. He has been a Scala enthusiast since he came to know this beautiful language in 2007. He started his professional career as a software developer in 2004, cutting his teeth with C++, STL, and Boost. Around the same time, Java fever was spreading and his interest was migrating to web-hosted distributed Java-delivered solutions to aid health departments in the discovery of disease outbreaks.

He introduced Scala into his company code base in 2007, and soon after he was infected by Scala fever, contributing to the Scala IDE, maven-scala-plugin and Scala itself. Today, Josh is the author of several open source Scala projects, including the Scala automated resource management library and the PGP sbt plugin, as well as contributing to key components in the Scala ecosystem, like the maven-scala-plugin. His current work at Typesafe Inc., has him doing everything from building MSIs to profiling performance issues.

Josh regularly shares his expertise in articles and talks. He likes short walks on the beach and dark beer.

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

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