Pragmatic Scala
Create Expressive, Concise, and Scalable Applications
by: Venkat Subramaniam
Published | 2015-09-18 |
---|---|
Internal code | vsscala2 |
Print status | In Print |
Pages | 286 |
User level | Intermediate |
Keywords | functional programming, haskall, erlang, scala, fp, multicore, multi-core, concurrency, jvm, vm, java vm |
Related titles | Programming Groovy 2 |
ISBN | 9781680500547 |
Other ISBN |
Channel epub: 9781680504200 Channel PDF: 9781680504217 Kindle: 9781680501544 Safari: 9781680501551 Kindle: 9781680501544 |
BISACs | COM051280 COMPUTERS / Programming Languages / JavaCOM048000 COMPUTERS / Systems Architecture / Distributed Systems & ComputingCOM048000 COMPUTERS / Systems Architecture / Distributed Systems & Computing |
Highlight
Our industry is moving toward functional programming, but your object-oriented experience is still valuable. Scala combines the power of OO and functional programming, and Pragmatic Scala shows you how to work effectively with both. Updated to Scala 2.11, with in-depth coverage of new features such as Akka actors, parallel collections, and tail call optimization, this book will show you how to create stellar applications.
Description
This thorough introduction to Scala will get you coding in this powerful language right away. You’ll start from the familiar ground of Java and, with easy-to-follow examples, you’ll learn how to create highly concise and expressive applications with Scala. You’ll find out when and how to mix both imperative and functional style, and how to use parallel collections and Akka actors to create high-performance concurrent applications that effectively use multicore processors.
Scala has evolved since the first edition of this book, and Pragmatic Scala is a significant update. We’ve revised each chapter, and added three new chapters and six new sections to explore the new features in Scala. You’ll learn how to:
- Safely manage concurrency with parallel collections and Akka actors
- Create expressive readable code with value classes and improved implicit conversions
- Create strings from data with no sweat using string interpolation
- Create domain-specific languages
- Optimize your recursions with tail call optimization
Whether you’re interested in creating concise, robust single-threaded applications or highly expressive, thread-safe concurrent programs, this book has you covered.
Contents and Extracts
- Getting Your Feet Wet
- Exploring Scala excerpt
- Scala Features
- More with Less
- Functional Programming
- Wrapping Up
- Taking Scala for a Ride
- Using the REPL
- Scala on the Command Line
- Running Scala Code as a Standalone Script
- Compiling Scala
- Wrapping Up
- From Java to Scala
- Scala as Concise Java
- Scala Classes for Java Primitives
- Tuples and Multiple Assignments
- Flexible Parameters and Arguments
- Implicit Parameters
- Strings and Multiline Raw Strings
- String Interpolation
- Sensible Defaults
- Operator Overloading
- Scala Surprises for the Java Eyes
- Default Access Modifier
- Wrapping Up
- Working with Objects
- Creating and Using Classes
- Following the JavaBean Convention
- Type Aliasing
- Extending a Class
- Parameterized Types
- Singletons and Companions
- Creating Enumerations
- Package Objects
- Wrapping Up
- Making Use of Types
- Type Inference
- Fundamental Types
- Return Type Inference
- Variance of Parameterized Type
- Implicit Type Conversions
- Value Classes
- Using Implicit Conversions
- Wrapping Up
- Exploring Scala excerpt
- Diving Into Scala
- Function Values and Closures excerpt
- Limitations of Normal Functions
- Extensibility with Higher Order Functions
- Function Values with Multiple Parameters
- Currying
- Positional Notation for Parameters
- Parameter Routing
- Reusing Function Values
- Partially Applied Functions
- Closures
- Execute Around Method Pattern
- Wrapping Up
- Traits
- Understanding Traits
- Selective Mixins
- Decorating with Traits
- Method Late Binding in Traits
- Wrapping Up
- Collections
- Common Scala Collections
- Using a Set
- Associative Maps
- Immutable Lists
- Method Name Convention
- The for Expression
- Wrapping Up
- Pattern Matching and Regular Expressions
- Comprehensive Matching
- Pattern Variables and Constants in case Expressions
- Matching Using case Classes
- Extractors and Regular Expressions
- The Omnipresent Underscore Character
- Wrapping Up
- Handling Exceptions
- Exceptions in Scala
- Mind the Catch Order
- Wrapping Up
- Programming Recursions excerpt
- A Simple Recursion
- Tail Call Optimization (TCO)
- Trampoline Calls
- Wrapping Up
- Function Values and Closures excerpt
- Concurrency in Scala
- Lazy Evaluations and Parallel Collections
- Let’s Get Lazy
- Making Strict Collections Lazy
- The Ultimately Lazy Streams
- Parallel Collections
- Wrapping Up
- Programming with Actors
- A Sequential Time-Consuming Problem
- The Treacherous Paths to Concurrency
- Creating Actors
- Actors and Threads
- Isolated Mutability
- Concurrency with Actors
- Usage Recommendations
- Wrapping Up
- Lazy Evaluations and Parallel Collections
- Applying Scala
- Intermixing with Java
- Using Scala Classes from Scala
- Using Java Classes from Scala
- Using Scala Methods from Java
- Using Traits from Java
- Using Singletons and Companion Objects from Java
- Extending Classes
- Wrapping Up
- Creating an Application with Scala
- Getting Users’ Input
- Reading and Writing Files
- XML as a First-Class Citizen
- Reading and Writing XML
- Getting Stock Prices from the Web
- Making the Net Asset Application Concurrent
- Wrapping Up
- Unit Testing
- Using JUnit
- Using ScalaTest
- Using Mockito
- Installing Scala
- Downloading
- Installing
- Web Resources
- Bibliography
- Intermixing with Java