Programming in Scala, Fourth Edition cover

Programming in Scala, Fourth Edition

Rating 4.8
Word count
1.1K words
Chapters
40
ISBN
9787121402722

Tags

Summary

Scala Programming is the authoritative official guide to the Scala language, written by Scala's creator Martin Odersky together with core team members Lex Spoon and Bill Venners, and translated into Chinese by senior architect Gao Yuxiang. The fourth edition corresponds to Scala 2.13, with the subtitle "Based on Scala 2.13," and runs to 34 chapters, covering everything from the language's design philosophy to its practical application.

The book opens with "a scalable language," explaining why Scala unites the object-oriented and functional paradigms, then uses "twelve steps to get started" to guide readers through hands-on familiarization with the interpreter, variables, functions, scripts, lists, tuples, sets, and maps. The main body systematically covers classes and objects, basic types and operations, functional objects, built-in control structures, functions and closures, control abstractions, composition and inheritance, traits, packages and imports, assertions and tests, case classes and pattern matching, lists and other collection classes, mutable objects, type parameterization, abstract members, implicit conversions and implicit parameters, and goes deeper into list implementation, revisiting for expressions, and the collections architecture.

Later chapters cover extractors, annotations, XML processing, modular programming with objects, object equality, Scala-Java interoperability, Futures and concurrent programming, and combinator parsing, concluding with a complete spreadsheet (SCells) case study. The most significant change in the fourth edition is a near-total rewrite of the collections framework in preparation for the transition to Scala 3, with substantial updates to collection inheritance hierarchies, implementations, methods, and views, expanding the book to nearly 850 pages. The book teaches not only "how to write" but also explains "why it is designed this way," helping readers understand the trade-offs behind language features. It is an indispensable reference for anyone seeking an in-depth study of Scala.

Editor's review

如果说有一本书可以被称作 Scala 领域的“圣经”,那一定是它。作者 Martin Odersky 正是 Scala 语言的设计者,书中讲的不是二手转述的用法,而是语言为何长成今天这个样子——类型系统为何如此设计、隐式转换要解决什么问题、集合框架为什么反复重构。这种“造物者视角”是市面上绝大多数 Scala 教程给不了的。 第4版紧跟 Scala 2.13,对集合类库做了几乎重写级的大幅更新,同时为 Scala 3 铺路,因此它既是一本学语言的教材,也是理解 Scala 演进方向的窗口。译者高宇翔是 Scala 在国内的早期布道者,术语译法稳妥,长句处理流畅,减少了阅读原版时的理解摩擦。 需要提醒的是,这本书更像“教材+参考手册”,而不是速查手册:34 章的体量、800 多页的篇幅,加上密集的示例与设计讨论,需要读者真正投入时间。对于有 Java 或其他面向对象语言经验、想系统吃透 Scala 的开发者,它值得占据书架最随手可及的位置。

Who it's for

A good fit for

  • 具备 Java 或其他面向对象语言基础,准备系统转向 Scala 的开发者
  • 已在工作中使用 Scala,希望补齐类型系统、隐式与集合框架知识的中级工程师
  • 需要理解函数式与面向对象融合范式,想从语言设计视角提升认知的程序员
  • 大数据方向(Spark、Kafka 等生态)开发者,需要扎实掌握 Scala 语言本身的人

Not a good fit for

  • 完全没有编程经验的零基础读者,书中假定读者熟悉面向对象基本概念
  • 只想快速查语法、抄代码的读者,本书更偏系统讲解而非速查手册
  • 只使用 Scala 3 且不愿阅读 2.13 语义细节的读者,部分内容与 Scala 3 已有差异

Reading tips

  1. 前 3 章务必边读边在 REPL 中敲示例,先把解释器、脚本和集合用法跑通再深入。
  2. 第 6、8、9、15、21 章是理解 Scala 思维的关键,建议放慢速度、配合习题手写代码。
  3. 第 22、24、25 章讲集合实现与架构,可在实际项目用到集合时再回读,效果更好。
  4. 把第 34 章 SCells 案例作为综合练习,独立复现一遍,检验对模式匹配与组合子解析的掌握。

About the publisher

Publishing House of Electronics Industry China · Founded in 1982

The Publishing House of Electronics Industry is a comprehensive publisher distinguished by its focus on electronic information and related fields. Judging from the more than 3,000 titles in its catalogue, its publishing covers programming and design, artificial intelligence, computer science, finance and economics, photography, and social sciences, attending both to cutting-edge technology and to general readers. Representative titles include Factor Investing: Methods and Practice, x86 Assembly Language: From Real Mode to Protected Mode, The RISC-V Reader, Artificial Intelligence: Speech Recognition, Understanding and Practice, Phased Array Radar Technology, Radar Target Characteristics, and 100 Go Mistakes and How to Avoid Them, most of which centre on technical methods and engineering practice. Its authors include Shi Chuan, Li Zhong, Wang Xiaobo, David Patterson, Andrew Waterman, and Yu Zihao, among others from China and abroad. Owing to limited public information, no further publishing features are elaborated here.

Contents

  1. Preface
  2. Acknowledgments
  3. Introduction
  4. Chapter 1 A Scalable Language
  5. Chapter 2 First Steps in Scala
  6. Chapter 3 Next Steps in Scala
  7. Chapter 4 Classes and Objects
  8. Chapter 5 Basic Types and Operations
  9. Chapter 6 Functional Objects
  10. Chapter 7 Built-in Control Structures
  11. Chapter 8 Functions and Closures
  12. Chapter 9 Control Abstraction
  13. Chapter 10 Composition and Inheritance
  14. Chapter 11 Scala's Hierarchy
  15. Chapter 12 Traits
  16. Chapter 13 Packages and Imports
  17. Chapter 14 Assertions and Tests
  18. Chapter 15 Case Classes and Pattern Matching
  19. Chapter 16 Working with Lists
  20. Chapter 17 Working with Other Collections
  21. Chapter 18 Mutable Objects
  22. Chapter 19 Type Parameterization
  23. Chapter 20 Abstract Members
  24. Chapter 21 Implicit Conversions and Parameters
  25. Chapter 22 Implementing Lists
  26. Chapter 23 For Expressions Revisited
  27. Chapter 24 Collections in Depth
  28. Chapter 25 The Architecture of Scala Collections
  29. Chapter 26 Extractors
  30. Chapter 27 Annotations
  31. Chapter 28 Working with XML
  32. Chapter 29 Modular Programming Using Objects
  33. Chapter 30 Object Equality
  34. Chapter 31 Combining Scala and Java
  35. Chapter 32 Futures and Concurrency
  36. Chapter 33 Combinator Parsing
  37. Chapter 34 The SCells Spreadsheet
  38. Appendix Scala Scripts on Unix and Windows
  39. Glossary
  40. About the Authors

FAQ

这本书适合完全没有编程基础的人吗?
不太适合。书中默认读者具备一定的编程经验,尤其熟悉类、对象、继承等面向对象概念,示例也常与 Java 对比。零基础读者建议先学习一门主流面向对象语言,再来阅读本书会顺畅很多。
第4版和第3版的主要区别是什么?
第4版对应 Scala 2.13,主要变化是集合类库几乎被重写、集合的继承关系与实现方式大幅调整,并新增集合方法、视图等内容,篇幅也由约 830 页增至 844 页。第3版基于较早的 Scala 版本,若使用 2.13 或准备迁移 Scala 3,应优先选第4版。
这本书讲的是 Scala 2 还是 Scala 3?
第4版副标题为“基于Scala 2.13”,内容以 Scala 2.13 为准,并在多处为 Scala 3 的语法与集合设计做铺垫。如果你主要使用 Scala 3,阅读时需注意 implicit、部分语法等已有变化,可配合官方迁移指南对照学习。
一定要按顺序从头读到尾吗?
建议前 3 章按顺序读并动手实践,建立基本语感;之后可按需跳读。已有 Scala 基础的读者可直接从第 6、12、15、21、24 章切入,遇到概念缺口再回补前文,效率更高。

Comments

Find this book

This site is an index: you start “Search all sources” in your browser, and the entries it lists all point to third-party sites; please judge their availability yourself.

More by the same author

Top rated in the same category