Home Page Icon
Home Page
Table of Contents for
Programming Scala
Close
Programming Scala
by Alex Payne, Dean Wampler
Programming Scala, 2nd Edition
Foreword
Preface
Welcome to Programming Scala, Second Edition
How to Read This Book
What Isn’t Covered?
Welcome to Programming Scala, First Edition
Conventions Used in This Book
Using Code Examples
Getting the Code Examples
O’Reilly Safari
How to Contact Us
Acknowledgments for the Second Edition
Acknowledgments for the First Edition
1. Zero to Sixty: Introducing Scala
Why Scala?
The Seductions of Scala
What About Java 8?
Installing Scala
Using SBT
Running the Scala Command-Line Tools
Running the Scala REPL in IDEs
A Taste of Scala
A Taste of Concurrency
Recap and What’s Next
2. Type Less, Do More
Semicolons
Variable Declarations
Ranges
Partial Functions
Method Declarations
Method Default and Named Arguments
Methods with Multiple Argument Lists
A Taste of Futures
Nesting Method Definitions and Recursion
Inferring Type Information
Reserved Words
Literal Values
Integer Literals
Floating-Point Literals
Boolean Literals
Character Literals
String Literals
Symbol Literals
Function Literals
Tuple Literals
Option, Some, and None: Avoiding nulls
Sealed Class Hierarchies
Organizing Code in Files and Namespaces
Importing Types and Their Members
Imports Are Relative
Package Objects
Abstract Types Versus Parameterized Types
Recap and What’s Next
3. Rounding Out the Basics
Operator Overloading?
Syntactic Sugar
Methods with Empty Argument Lists
Precedence Rules
Domain-Specific Languages
Scala if Statements
Scala for Comprehensions
for Loops
Generator Expressions
Guards: Filtering Values
Yielding
Expanded Scope and Value Definitions
Other Looping Constructs
Scala while Loops
Scala do-while Loops
Conditional Operators
Using try, catch, and finally Clauses
Call by Name, Call by Value
lazy val
Enumerations
Interpolated Strings
Traits: Interfaces and “Mixins” in Scala
Recap and What’s Next
4. Pattern Matching
A Simple Match
Values, Variables, and Types in Matches
Matching on Sequences
Matching on Tuples
Guards in case Clauses
Matching on case Classes
unapply Method
unapplySeq Method
Matching on Variable Argument Lists
Matching on Regular Expressions
More on Binding Variables in case Clauses
More on Type Matching
Sealed Hierarchies and Exhaustive Matches
Other Uses of Pattern Matching
Concluding Remarks on Pattern Matching
Recap and What’s Next
5. Implicits
Implicit Arguments
Using implicitly
Scenarios for Implicit Arguments
Execution Contexts
Capabilities
Constraining Allowed Instances
Implicit Evidence
Working Around Erasure
Improving Error Messages
Phantom Types
Rules for Implicit Arguments
Implicit Conversions
Build Your Own String Interpolator
The Expression Problem
Type Class Pattern
Technical Issues with Implicits
Implicit Resolution Rules
Scala’s Built-in Implicits
Wise Use of Implicits
Recap and What’s Next
6. Functional Programming in Scala
What Is Functional Programming?
Functions in Mathematics
Variables That Aren’t
Functional Programming in Scala
Anonymous Functions, Lambdas, and Closures
Purity Inside Versus Outside
Recursion
Tail Calls and Tail-Call Optimization
Trampoline for Tail Calls
Partially Applied Functions Versus Partial Functions
Currying and Other Transformations on Functions
Functional Data Structures
Sequences
Maps
Sets
Traversing, Mapping, Filtering, Folding, and Reducing
Traversal
Mapping
Flat Mapping
Filtering
Folding and Reducing
Left Versus Right Traversals
Tail Recursion Versus Traversals of Infinite Collections
Combinators: Software’s Best Component Abstractions
What About Making Copies?
Recap and What’s Next
7. for Comprehensions in Depth
Recap: The Elements of for Comprehensions
for Comprehensions: Under the Hood
Translation Rules of for Comprehensions
Options and Other Container Types
Option as a Container
Either: A Logical Extension to Option
Try: When There Is No Do
Scalaz Validation
Recap and What’s Next
8. Object-Oriented Programming in Scala
Class and Object Basics
Reference Versus Value Types
Value Classes
Parent Types
Constructors in Scala
Fields in Classes
The Uniform Access Principle
Unary Methods
Validating Input
Calling Parent Class Constructors (and Good Object-Oriented Design)
Good Object-Oriented Design: A Digression
Nested Types
Recap and What’s Next
9. Traits
Interfaces in Java 8
Traits as Mixins
Stackable Traits
Constructing Traits
Class or Trait?
Recap and What’s Next
10. The Scala Object System, Part I
Parameterized Types: Variance Under Inheritance
Functions Under the Hood
Variance of Mutable Types
Variance in Scala Versus Java
The Scala Type Hierarchy
Much Ado About Nothing (and Null)
Products, Case Classes, and Tuples
The Predef Object
Implicit Conversions
Type Definitions
Condition Checking Methods
Input and Output Methods
Miscellaneous Methods
Equality of Objects
The equals Method
The == and != Methods
The eq and ne Methods
Array Equality and the sameElements Method
Recap and What’s Next
11. The Scala Object System, Part II
Overriding Members of Classes and Traits
Avoid Overriding Concrete Members
Attempting to Override final Declarations
Overriding Abstract and Concrete Methods
Overriding Abstract and Concrete Fields
Overriding Abstract Types
When Accessor Methods and Fields Are Indistinguishable: The Uniform Access Principle
Linearization of an Object’s Hierarchy
Recap and What’s Next
12. The Scala Collections Library
Generic, Mutable, Immutable, Concurrent, and Parallel Collections, Oh My!
The scala.collection Package
The collection.concurrent Package
The collection.convert Package
The collection.generic Package
The collection.immutable Package
The scala.collection.mutable Package
The scala.collection.parallel Package
Choosing a Collection
Design Idioms in the Collections Library
Builder
CanBuildFrom
Like Traits
Specialization for Value Types
Miniboxing
Recap and What’s Next
13. Visibility Rules
Public Visibility: The Default
Visibility Keywords
Public Visibility
Protected Visibility
Private Visibility
Scoped Private and Protected Visibility
Final Thoughts on Visibility
Recap and What’s Next
14. Scala’s Type System, Part I
Parameterized Types
Variance Annotations
Type Constructors
Type Parameter Names
Type Bounds
Upper Type Bounds
Lower Type Bounds
Context Bounds
View Bounds
Understanding Abstract Types
Comparing Abstract Types and Parameterized Types
Self-Type Annotations
Structural Types
Compound Types
Type Refinements
Existential Types
Recap and What’s Next
15. Scala’s Type System, Part II
Path-Dependent Types
C.this
C.super
path.x
Dependent Method Types
Type Projections
Singleton Types
Types for Values
Tuple Types
Function Types
Infix Types
Higher-Kinded Types
Type Lambdas
Self-Recursive Types: F-Bounded Polymorphism
Recap and What’s Next
16. Advanced Functional Programming
Algebraic Data Types
Sum Types Versus Product Types
Properties of Algebraic Data Types
Final Thought on Algebraic Data Types
Category Theory
About Categories
The Functor Category
The Monad Category
The Importance of Monad
Recap and What’s Next
17. Tools for Concurrency
The scala.sys.process Package
Futures
Async
Robust, Scalable Concurrency with Actors
Akka: Actors for Scala
Actors: Final Thoughts
Pickling and Spores
Reactive Programming
Recap and What’s Next
18. Scala for Big Data
Big Data: A Brief History
Improving MapReduce with Scala
Moving Beyond MapReduce
Categories for Mathematics
A List of Scala-Based Data Tools
Recap and What’s Next
19. Dynamic Invocation in Scala
A Motivating Example: ActiveRecord in Ruby on Rails
Dynamic Invocation in Scala with the Dynamic Trait
DSL Considerations
Recap and What’s Next
20. Domain-Specific Languages in Scala
Examples: XML and JSON DSLs for Scala
Internal DSLs
External DSLs with Parser Combinators
About Parser Combinators
A Payroll External DSL
Internal Versus External DSLs: Final Thoughts
Recap and What’s Next
21. Scala Tools and Libraries
Command-Line Tools
scalac Command-Line Tool
The scala Command-Line Tool
The scalap and javap Command-Line Tools
The scaladoc Command-Line Tool
The fsc Command-Line Tool
Build Tools
SBT, the Standard Build Tool for Scala
Other Build Tools
Integration with IDEs and Text Editors
Text Editors
Test-Driven Development in Scala
Third-Party Libraries
Recap and What’s Next
22. Java Interoperability
Using Java Names in Scala Code
Java and Scala Generics
JavaBean Properties
AnyVal Types and Java Primitives
Scala Names in Java Code
Recap and What’s Next
23. Application Design
Recap of What We Already Know
Annotations
Traits as Modules
Design Patterns
Creational Patterns
Structural Patterns
Behavioral Patterns
Better Design with Design by Contract
The Parthenon Architecture
Recap and What’s Next
24. Metaprogramming: Macros and Reflection
Tools for Understanding Types
Runtime Reflection
Reflecting on Types
Class Tags, Type Tags, and Manifests
Scala’s Advanced Runtime Reflection API
Macros
A Macro Example: Enforcing Invariants
Final Thoughts on Macros
Wrapping Up and Looking Ahead
A. References
Index
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Next
Next Chapter
Programming Scala
Programming Scala
Second Edition
Dean Wampler and Alex Payne
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset