وبلاگ بلیان

Learning Scala: Practical Functional Programming for the JVM

معرفی کتاب «Learning Scala: Practical Functional Programming for the JVM» نوشتهٔ Jason Swartz، منتشرشده توسط نشر O'Reilly Media در سال 2014. این کتاب در 255 صفحه، فرمت pdf، زبان انگلیسی ارائه شده است. «Learning Scala: Practical Functional Programming for the JVM» در دستهٔ بدون دسته‌بندی قرار دارد.

O’Reilly, 2015. — 255 p. — ISBN: 9781449367930 This book is meant for developers who have worked in object-oriented languages such as Java, Ruby, or Python and are interested in improving their craft by learning Scala. Java developers will recognize the core object-oriented, static typing and generic collections in Scala. However, they may be challenged to switch to Scala’s more expressive and flexible syntax, and the use of immutable data and function literals to solve problems. Ruby and Python developers will be familiar with the use of function literals (aka closures or blocks) to work with collections, but may be challenged with its static, generic-supporting type system. For these and any other developers who want to learn how to develop in the Scala programming language, this book provides an organized and examples-based guide that follows a gradual learning curve. Copyright 4 Table of Contents 7 Preface 11 Who This Book Is For 11 Why Write “Learning Scala”? 11 Why Learn Scala (or, Why Should You Read “Learning Scala”)? 12 Reason 1—Your Code Will Be Better 12 Reason 2—You’ll Be a Better Engineer 12 Reason 3—You’ll Be a Happier Engineer 13 Why Learning Scala May Not Be for You 13 About the Syntax Notation in This Book 14 Conventions Used in This Book 14 Using Code Examples 15 Safari® Books Online 16 How to Contact Us 16 Acknowledgments 17 Part I. Core Scala 19 Chapter 1. Getting Started with the Scalable Language 21 Installing Scala 21 Using the Scala REPL 22 Summary 24 Exercises 24 Chapter 2. Working with Data: Literals, Values, Variables, and Types 27 Values 28 Variables 30 Naming 31 Types 33 Numeric Data Types 33 Strings 35 An Overview of Scala Types 39 Tuples 43 Summary 44 Exercises 44 Chapter 3. Expressions and Conditionals 45 Expressions 45 Defining Values and Variables with Expressions 46 Expression Blocks 46 Statements 47 If..Else Expression Blocks 48 If Expressions 48 If-Else Expressions 49 Match Expressions 49 Matching with Wildcard Patterns 52 Matching with Pattern Guards 54 Matching Types with Pattern Variables 54 Loops 55 Iterator Guards 57 Nested Iterators 57 Value Binding 58 While and Do/While Loops 58 Summary 59 Exercises 60 Chapter 4. Functions 63 Procedures 66 Functions with Empty Parentheses 66 Function Invocation with Expression Blocks 67 Recursive Functions 68 Nested Functions 70 Calling Functions with Named Parameters 71 Parameters with Default Values 71 Vararg Parameters 72 Parameter Groups 73 Type Parameters 73 Methods and Operators 75 Writing Readable Functions 78 Summary 80 Exercises 80 Chapter 5. First-Class Functions 83 Function Types and Values 84 Higher-Order Functions 86 Function Literals 87 Placeholder Syntax 90 Partially Applied Functions and Currying 92 By-Name Parameters 93 Partial Functions 94 Invoking Higher-Order Functions with Function Literal Blocks 96 Summary 98 Exercises 99 Chapter 6. Common Collections 101 Lists, Sets, and Maps 101 What’s in a List? 104 The Cons Operator 107 List Arithmetic 108 Mapping Lists 110 Reducing Lists 111 Converting Collections 116 Java and Scala Collection Compatibility 117 Pattern Matching with Collections 118 Summary 119 Exercises 120 Chapter 7. More Collections 125 Mutable Collections 125 Creating New Mutable Collections 126 Creating Mutable Collections from Immutable Ones 127 Using Collection Builders 129 Arrays 130 Seq and Sequences 131 Streams 133 Monadic Collections 135 Option Collections 135 Try Collections 139 Future Collections 143 Summary 148 Exercises 149 Part II. Object-Oriented Scala 153 Chapter 8. Classes 155 Defining Classes 160 More Class Types 164 Abstract Classes 164 Anonymous Classes 166 More Field and Method Types 167 Overloaded Methods 167 Apply Methods 168 Lazy Values 168 Packaging 169 Accessing Packaged Classes 170 Packaging Syntax 174 Privacy Controls 176 Privacy Access Modifiers 178 Final and Sealed Classes 179 Summary 180 Exercises 180 Chapter 9. Objects, Case Classes, and Traits 185 Objects 185 Apply Methods and Companion Objects 187 Command-Line Applications with Objects 190 Case Classes 191 Traits 194 Self Types 198 Instantiation with Traits 200 Importing Instance Members 202 Summary 203 Break—Configuring Your First Scala Project 204 Exercises 209 Chapter 10. Advanced Typing 217 Tuple and Function Value Classes 219 Implicit Parameters 221 Implicit Classes 223 Types 225 Type Aliases 225 Abstract Types 226 Bounded Types 227 Type Variance 230 Package Objects 234 Summary 235 Questions 236 Appendix A. Reserved Words 239 Index 243 About the Author 255 Why learn Scala? You don’t need to be a data scientist or distributed computing expert to appreciate this object-oriented functional programming language. This practical book provides a comprehensive yet approachable introduction to the language, complete with syntax diagrams, examples, and exercises. You’ll start with Scala's core types and syntax before diving into higher-order functions and immutable data structures.Author Jason Swartz demonstrates why Scala’s concise and expressive syntax make it an ideal language for Ruby or Python developers who want to improve their craft, while its type safety and performance ensures that it’s stable and fast enough for any application.Learn about the core data types, literals, values, and variablesDiscover how to think and write in expressions, the foundation for Scala's syntaxWrite higher-order functions that accept or return other functionsBecome familiar with immutable data structures and easily transform them with type-safe and declarative operationsCreate custom infix operators to simplify existing operations or even to start your own domain-specific languageBuild classes that compose one or more traits for full reusability, or create new functionality by mixing them in at instantiation Why learn Scala? You don't need to be a data scientist or distributed computing expert to appreciate this object-oriented functional programming language. This practical book provides a comprehensive yet approachable introduction to the language, complete with syntax diagrams, examples, and exercises. You'll start with Scala's core types and syntax before diving into higher-order functions and immutable data structures. Author Jason Swartz demonstrates why Scala's concise and expressive syntax make it an ideal language for Ruby or Python developers who want to improve their craft, while its type safety and performance ensures that it's stable and fast enough for any application. Learn about the core data types, literals, values, and variables Discover how to think and write in expressions, the foundation for Scala's syntax Write higher-order functions that accept or return other functions Become familiar with immutable data structures and easily transform them with type-safe and declarative operations Create custom infix operators to simplify existing operations or even to start your own domain-specific language Build classes that compose one or more traits for full reusability, or create new functionality by mixing them in at instantiation Learning Scala is an introduction and a guide to getting started with functional programming (FP) development. Written for programmers who are already familiar with object-oriented (OO) development, the book introduces the reader to the core Scala syntax and its OO models with examples and solutions that build familiarity, experience and confidence with the language. The more challenging topics of Scala development (immutable data, anonymous functions, strong typing, flexible syntax) are introduced later in the book and build on the earlier problems to assist understanding. New concepts will be demonstrated and explained before being used in coding problems or samples so that readers will be able to progress through the chapters sequentially and not be forced to browse for answers. Scala has a deserved reputation as being difficult to learn, with a steep and extensive learning curve and unfamiliar syntax. This book is designed to address those difficulties. "Learn about the core data types, literals, values, and variables Discover how to think and write in expressions, the foundation for Scala's syntax Write higher-order functions that accept or return other functions Become familiar with immutable data structures and easily transform them with type-safe and declarative operations Create custom infix operators to simplify existing operations or even to start your own domain-specific language Build classes that compose one or more traits for full reusability, or create new functionality by mixing them in at instantiation"--Publisher Written for programmers who are already familiar with object-oriented (OO) development, the book introduces you to the core Scala syntax and its OO models with examples and solutions that build familiarity, experience, and confidence with the language.
دانلود کتاب Learning Scala: Practical Functional Programming for the JVM