Programming in Scala (Third Edition) cover

Programming in Scala (Third Edition)

Rating 4.5
Word count
1.2K words
Chapters
40
ISBN
9787121328428

Tags

Summary

This book is one of the authoritative tutorials and references on the Scala language, co-authored by Martin Odersky, the creator of Scala, together with Lex Spoon and Bill Venners; the Chinese edition is translated by Gao Yuxiang, long engaged in promoting and translating Scala. The book addresses developers with some programming experience and proceeds step by step: it begins with a small program that can be written in a few lines, giving readers a quick feel for Scala; it then moves in turn through classes and objects, basic types and operations, functions and closures, control abstraction, composition and inheritance, traits, packages and imports, assertions and tests, and case classes and pattern matching. After the language basics, the book discusses lists and other collection classes, mutable objects, type parameterization, abstract members, implicit conversions and implicit parameters, the implementation of lists, for expressions, the Scala collections architecture, extractors, annotations, XML processing, modular programming with objects, object equality, and interoperability between Scala and Java, closing with futures and concurrent programming, combinator parsing, GUI programming, and a complete spreadsheet (SCells) case study that shows how to combine these features to build real programs. The third edition is updated for Scala 2.12 and adds string interpolation, futures and concurrency (including methods new in 2.12 and asynchronous testing in ScalaTest 3.0), wildcard types, advice on writing hashCode, deep integration of Scala 2.12 with Java 8 (such as implementing SAM types with function literals), implicit classes, custom AnyVal, and context-bound syntax for type classes. Throughout, the book emphasizes why the language is designed as it is, helping readers not only write Scala but understand the motivations behind its trade-offs; its functional and object-oriented ideas are valuable even to readers who do not use Scala directly.

Editor's review

市面上讲 Scala 的书不少,但由语言设计者本人系统写下来的,只有这一本。《Scala编程》自第1版起就被视为 Scala 领域的“正典”,第3版跟进到 Scala 2.12,把字符串插值、Future 与并发、隐式类、AnyVal、SAM 转换、上下文界定等新特性都纳入了讲解。 它的写法与速查型书籍不同:不满足于告诉你“这样写能跑”,而是解释语言为什么这样设计、在面向对象与函数式之间做了哪些取舍。许多读者反馈,读完前几章的入门示例后,对 Scala 的语法糖不再感到突兀;读到特质、隐式、集合架构等章节时,才真正理解这门语言的组织方式。第29章“用对象实现模块化编程”、第30章“对象相等性”、第25章“Scala集合架构”这几章尤其能体现作者的功力。 中文版由高宇翔翻译,他此前译过《快学Scala》与《Scala编程》第1版,术语处理较为稳定。全书832页、约123万字,属于需要长期放在案头反复查阅的类型。 需要提醒的是:这是一本讲语言本身的书,不是框架实战手册,也不覆盖 Scala 3。如果你的目标是尽快上手 Spark 或 Akka,它可以作为底座,但不该是唯一一本。

Who it's for

A good fit for

  • 已掌握 Java 或其他主流语言、希望系统学习 Scala 的开发者
  • 需要理解函数式与面向对象如何融合的中高级程序员
  • 使用 Spark、Akka 等 Scala 生态框架,想补足语言基础的数据工程师
  • 讲授编程语言、函数式编程课程的高校教师与研究生

Not a good fit for

  • 完全没有编程经验的零基础读者,入门示例的跨度偏大
  • 只想学 Scala 3 新语法(given、enum、上下文抽象)的读者,本书基于 Scala 2.12
  • 急需框架实战配方、希望照抄代码解决业务问题的人

Reading tips

  1. 第1—3章可快速通读,感受 Scala 的写法;第4—15章建议逐章跟敲示例,打牢语法与对象模型。
  2. 第21章隐式转换、第25章集合架构、第29章模块化编程是难点,可先读一遍留印象,实践中再回看。
  3. 把第35章 SCells 试算表当作综合练习,边读边运行,检验前面各章特性的串联效果。
  4. 若时间有限,可先读第1、6、10、12、15、16、19、21章,掌握最常用的语言骨架,其余作为参考查阅。

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 Scala Collections Architecture
  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 GUI Programming
  38. Chapter 35 The SCells Spreadsheet
  39. Appendix A Scala Scripts on Unix and Windows
  40. Glossary

FAQ

这本书讲的是 Scala 2 还是 Scala 3?
中文版《Scala编程(第3版)》对应英文版 Programming in Scala 第三版,内容基于 Scala 2.12,涵盖该版本的字符串插值、Future 等特性,不涉及 Scala 3 的 given、enum 等新语法。
零基础可以直接读这本书吗?
不太建议。本书明确面向有一定编程经验的开发者,讲解偏重语言设计与原理。若有 Java 或其他面向对象语言基础,读起来会顺畅得多;完全没有编程经验者宜先读一本通用入门书。
和《快学Scala》有什么区别?
《快学Scala》偏重快速上手与要点速查,篇幅紧凑;本书由语言设计者撰写,讲解更系统、更深入设计动因,适合作为长期案头参考。两者译者均为高宇翔。
中文版的结构和英文原版一致吗?
一致。中文版对应英文第三版,共35章,从“一门可伸缩的语言”讲到 SCells 试算表,另含附录A“Unix和Windows环境的Scala脚本”与术语表,全书832页。
书里的代码示例还能直接运行吗?
大部分示例基于 Scala 2.12,在 Scala 2.13 上多数仍可运行,但集合类与部分 API 存在调整。建议用 2.12 或 2.13 环境对照练习,遇到编译错误优先查对应版本的 API 文档。

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