当前位置:首页 > 工业技术
Scala编程  第2版  英文
Scala编程  第2版  英文

Scala编程 第2版 英文PDF电子书下载

工业技术

  • 电子书积分:17 积分如何计算积分?
  • 作 者:(美)万普勒,(美)佩恩著
  • 出 版 社:南京:东南大学出版社
  • 出版年份:2015
  • ISBN:9787564159221
  • 页数:558 页
图书介绍:Scala这种JVM语言通过新式对象模型、函数式编程和高级类型系统带来的优势提升了语言的运行效率。这本综合性的书籍包含了大量的程序代码示例,向你展示如何在开发中利用语言和生态系统而立刻变得更具有效率,同时解释了对于当今支持并发和分布式的高度可扩展的、以数据为中心应用程序而言, Scala为什么是一个理想选择。第二版包含了最新的语言特性,加入了关于模式匹配、推导和高级函数式编程的新章节。同时你也可以学习到Scala的命令行工具、第三方工具、库、面向编辑器和集成开发环境的语言感知插件。这本书是初级和高级Scala开发人员的理想选择。
上一篇:塑胶大全下一篇:采矿工程
《Scala编程 第2版 英文》目录
标签:编程

1.Zero to Sixty:Introducing Scala 1

Why Scala? 1

The Seductions of Scala 2

What About Java 8? 3

Installing Scala 3

Using SBT 5

Running the Scala Command-Line Tools 7

Running the Scala REPL in IDEs 9

A Taste of Scala 9

A Taste of Concurrency 19

Recap and What's Next 30

2.Type Less,Do More 33

Semicolons 33

Variable Declarations 34

Ranges 36

Partial Functions 37

Method Declarations 38

Method Default and Named Arguments 38

Methods with Multiple Argument Lists 39

A Taste of Futures 41

Nesting Method Definitions and Recursion 43

Inferring Type Information 46

Reserved Words 51

Literal Values 53

Integer Literals 54

Floating-Point Literals 55

Boolean Literals 55

Character Literals 56

String Literals 56

Symbol Literals 58

Function Literals 58

Tuple Literals 59

Option,Some,and None:Avoiding nulls 60

Sealed Class Hierarchies 62

Organizing Code in Files and Namespaces 63

Importing Types and Their Members 65

Imports Are Relative 66

Package Objects 66

Abstract Types Versus Parameterized Types 67

Recap and What's Next 70

3.RoundingOuttheBasics 71

Operator Overloading? 71

Syntactic Sugar 74

Methods with Empty Argument Lists 74

Precedence Rules 75

Domain-Specific Languages 76

Scala if Statements 77

Scala for Comprehensions 78

for Loops 78

Generator Expressions 79

Guards:Filtering Values 79

Yielding 80

Expanded Scope and Value Definitions 81

Other Looping Constructs 83

Scala while Loops 83

Scala do-while Loops 83

Conditional Operators 84

Using try,catch,and finally Clauses 84

Call by Name,Call by Value 87

lazy val 91

Enumerations 92

Interpolated Strings 94

Traits:Interfaces and"Mixins"in Scala 96

Recap and What's Next 99

4.PatternMatching 101

A Simple Match 101

Values,Variables,and Types in Matches 102

Matching on Sequences 106

Matching on Tuples 110

Guards in case Clauses 111

Matching on case Classes 111

unapply Method 113

unapplySeq Method 117

Matching on Variable Argument Lists 119

Matching on Regular Expressions 120

More on Binding Variables in case Clauses 121

More on Type Matching 122

Sealed Hierarchies and Exhaustive Matches 123

Other Uses of Pattern Matching 126

Concluding Remarks on Pattern Matching 129

Recap and What's Next 130

5.Implicits 131

Implicit Arguments 131

Using implicitly 133

Scenarios for Implicit Arguments 134

Execution Contexts 134

Capabilities 135

Constraining Allowed Instances 135

Implicit Evidence 140

Working Around Erasure 142

Improving Error Messages 144

Phantom Types 145

Rules for Implicit Arguments 148

Implicit Conversions 149

Build Your Own String Interpolator 153

The Expression Problem 155

Type Class Pattern 156

Technical Issues with Implicits 158

Implicit Resolution Rules 160

Scala's Built-in Implicits 161

Wise Use of Implicits 168

Recap and What's Next 168

6.Functional Programmingin Scala 169

What Is Functional Programming? 170

Functions in Mathematics 170

Variables That Aren't 171

Functional Programming in Scala 174

Anonymous Functions,Lambdas,and Closures 175

Purity Inside Versus Outside 178

Recursion 178

Tail Calls and Tail-Call Optimization 179

Trampoline for Tail Calls 180

Partially Applied Functions Versus Partial Functions 181

Currying and Other Transformations on Functions 183

Functional Data Structures 187

Sequences 187

Maps 192

Sets 194

Traversing,Mapping,Filtering,Folding,and Reducing 194

Traversal 195

Mapping 196

Flat Mapping 198

Filtering 199

Folding and Reducing 201

Left Versus Right Traversals 206

Tail Recursion Versus Traversals of Infinite Collections 209

Combinators:Software's Best Component Abstractions 212

What About Making Copies? 216

Recap and What's Next 218

7.forComprehensionsinDepth 221

Recap:The Elements of for Comprehensions 221

for Comprehensions:Under the Hood 224

Translation Rules of for Comprehensions 226

Options and Other Container Types 230

Option as a Container 230

Either:A Logical Extension to Option 234

Try:When There Is No Do 238

Scalaz Validation 240

Recap and What's Next 243

8.Object-Oriented Programmingin Scala 245

Class and Object Basics 246

Reference Versus Value Types 248

Value Classes 250

Parent Types 253

Constructors in Scala 254

Fields in Classes 258

The Uniform Access Principle 260

Unary Methods 261

Validating Input 261

Calling Parent Class Constructors(and Good Object-Oriented Design) 263

Good Object-Oriented Design:A Digression 264

Nested Types 269

Recap and What's Next 270

9.Traits 271

Interfacesin Java 8 271

Traits as Mixins 272

Stackable Traits 277

Constructing Traits 282

Classor Trait? 283

Recap and What's Next 284

10.The Scala Object System,PartⅠ 285

Parameterized Types:Variance Under Inheritance 285

Functions Under the Hood 286

Variance of Mutable Types 290

Variance in Scala Versus Java 292

The Scala Type Hierarchy 294

Much Ado About Nothing(and Null) 295

Products,Case Classes,and Tuples 299

The Predef Object 301

Implicit Conversions 301

Type Definitions 304

Condition Checking Methods 305

Input and Output Methods 305

Miscellaneous Methods 307

Equality of Objects 308

The equals Method 308

The==and!=Methods 309

The eq and ne Methods 309

Array Equality and the same Elements Method 310

Recap and What's Next 310

11.The Scala Object System,Part Ⅱ 311

Overriding Members of Classes and Traits 311

Avoid Overriding Concrete Members 312

Attempting to Override final Declarations 314

Overriding Abstract and Concrete Methods 315

Overriding Abstract and Concrete Fields 317

Overriding Abstract Types 323

When Accessor Methods and Fields Are Indistinguishable:The Uniform Access Principle 324

Linearization of an Object's Hierarchy 326

Recap and What's Next 331

12.The Scala Collections Library 333

Generic,Mutable,Immutable,Concurrent,and Parallel Collections,Oh My! 333

The scala.collection Package 334

The collection.concurrent Package 336

The collection.convert Package 336

The collection.generic Package 336

The collection.immutable Package 336

The scala.collection.mutable Package 338

The scala.collection.parallel Package 339

Choosing a Collection 341

Design Idioms in the Collections Library 342

Builder 342

Can Build From 343

Like Traits 344

Specialization for Value Types 345

Miniboxing 346

Recap and What'sNext 347

13.Visibility Rules 349

Public Visibility:The Default 349

Visibility Keywords 350

Public Visibility 351

Protected Visibility 352

Private Visibility 353

Scoped Private and Protected Visibility 355

Final Thoughts on Visibility 361

Recap and What'sNext 362

14.Scala's Type System,Part Ⅰ 363

Parameterized Types 364

Variance Annotations 364

Type Constructors 364

Type Parameter Names 364

Type Bounds 365

Upper Type Bounds 365

Lower Type Bounds 366

Context Bounds 370

View Bounds 371

Understanding Abstract Types 373

Comparing Abstract Types and Parameterized Types 374

Self-Type Annotations 376

Structural Types 381

Compound Types 385

Type Refinements 385

Existential Types 386

Recap and What's Next 388

15.Scala'sTypeSystem,Part Ⅱ 389

Path-Dependent Types 389

C.this 390

C.super 390

path.x 391

Dependent Method Types 392

Type Projections 393

Singleton Types 395

Types for Values 396

Tuple Types 396

Function Types 397

Infix Types 397

Higher-Kinded Types 398

Type Lambdas 402

Self-Recursive Types:F-Bounded Polymorphism 404

Recap and What's Next 405

16.Advanced Functional Programming 407

Algebraic Data Types 407

Sum Types Versus Product Types 407

Properties of Algebraic Data Types 409

Final Thought on Algebraic Data Types 410

Category Theory 410

About Categories 411

The Functor Category 412

The Monad Category 417

The Importance ofMonad 418

Recap and What's Next 420

17.Tools for Concurrency 423

The scala.sys.process Package 423

Futures 425

Async 428

Robust,Scalable Concurrency with Actors 429

Akka:Actors for Scala 430

Actors:Final Thoughts 441

Pickling and Spores 442

Reactive Programming 443

Recap and What's Next 444

18.Scala for Big Data 445

Big Data:A Brief History 445

Improving Map Reduce with Scala 447

Moving Beyond Map Reduce 452

Categories for Mathematics 453

A List of Scala-Based Data Tools 454

Recap and What's Next 455

19.Dynamic Invocation in Scala 457

A Motivating Example:ActiveRecord in Ruby on Rails 457

Dynamic Invocation in Scala with the Dynamic Trait 458

DSL Considerations 463

Recap andWhat'sNext 463

20.Domain-Specific Languages in Scala 465

Examples:XML and JSON DSLs for Scala 466

Internal DSLs 468

External DSLs with Parser Combinators 473

About Parser Combinators 473

A Payroll External DSL 473

Internal Versus External DSLs:Final Thoughts 476

Recap and What's Next 477

21.Scala Tools and Libraries 479

Command-Line Tools 479

scalac Command-Line Tool 479

The scala Command-Line Tool 483

The scalap and iavap Command-Line Tools 487

The scaladoc Command-Line Tool 488

The fsc Command-Line Tool 488

Build Tools 488

SBT, the Standard Build Tool for Scala 488

Other Build Tools 490

Integration with IDEs and Text Editors 491

Text Editors 492

Test-Driven Development in Scala 492

Third-Party Libraries 493

Recap and What's Next 495

22.Java Interoperability 497

Using Java Names in Scala Code 497

Java and Scala Generics 497

JavaBean Properties 499

AnyVal Types and Java Primitives 501

Scala Names in Java Code 501

Recap and What's Next 501

23.Application Design 503

Recap of What We Already Know 503

Annotations 504

Traits as Modules 508

Design Patterns 510

Creational Patterns 510

Structural Patterns 511

Behavioral Patterns 512

Better Design with Design by Contract 514

The Parthenon Architecture 517

Recap and What's Next 522

24.Metaprogramming:Macros and Reflection 523

Tools for Understanding Types 524

Runtime Reflection 524

Reflecting on Types 525

Class Tags,Type Tags,and Manifests 526

Scala's Advanced Runtime Reflection API 527

Macros 531

A Macro Example:Enforcing Invariants 533

Final Thoughts on Macros 536

Wrapping Up and Looking Ahead 537

A.References 539

Index 545

相关图书
作者其它书籍
返回顶部