Beautiful JavaScript cover

Beautiful JavaScript

No rating yet
Word count
198 words
Chapters
40
ISBN
9787519813642

Tags

Summary

Beautiful JavaScript (originally published by O'Reilly Media) is an essay collection written by a group of experts in front-end and JavaScript, edited by Anton Kovalyov. The simplified Chinese edition was published by China Electric Power Press in December 2017, translated by Du Chunxiao and Si Weiwei. The book has 14 chapters, each written by a different author and centered on a specific technical or conceptual theme: one starts from prototypes and inheritance to discuss how mixins can replace traditional class-based inheritance for code reuse; another examines the entanglement between eval and domain-specific languages, distinguishing its legitimate uses and risks in scenarios such as template compilation, multi-language mixing, and binary pattern matching; still another begins with a seemingly playful topic like how to draw a bunny to explore the diversity of expressive forms and the pedagogical value of code style. The book also covers style conventions in team collaboration, identity and environment models in constructor design, writing a parser and evaluator for mathematical expressions in JavaScript, the evolution of the Backbone framework, error handling across browsers and Node.js, the Node.js event loop and asynchronous non-blocking I/O, and functional programming in JavaScript. The book does not aim to be a syntax manual but treats language features as expressive tools: why a language born in haste can keep evolving and dominate the Web for so long, while many more orderly designs have faded to the margins. The chapters are short and varied in perspective, suited to readers who have mastered basic syntax and want to broaden their aesthetic and engineering judgment about JavaScript.

Editor's review

市面上讲 JavaScript 的书大体分两类:一是砖头厚的语法大全,二是聚焦某个框架的实战手册。这本《JavaScript之美》两头都不占,它更像一本“工程师随笔集”——十四位在各自领域做出过实际东西的人,各自挑一个自己真正感兴趣的点,讲透一种思路。 它的好处是视野杂而有序。讲 mixin 的一章会让你重新想一想“复用”到底是什么;讲 eval 的一章没有停留在“永远别用”的口号上,而是把它放回模板编译、DSL 这些真实场景里衡量;讲解析器与求值器的一章只有几十页,却把词法分析、语法树、遍历求值这条链路完整走了一遍,是很多人第一次亲手写出解释器的入门起点;讲事件循环与错误处理的章节,则直接指向 Node.js 日常开发中最容易踩坑的地方。 篇幅只有一百五十多页,字数十万字出头,一周内可以读完,但几乎每章都会留下一个值得自己动手验证的点子。中文版译文平实,术语处理比较稳妥。需要提醒的是,原书英文版成书于 2015 年,部分示例与生态讨论(如 Backbone 的演进)已显年代感,读者应把它当作启发思路的书,而不是查阅 API 的工具书。

Who it's for

A good fit for

  • 已掌握 JavaScript 基础语法、想提升代码品味与设计判断的前端开发者
  • 对语言机制、DSL、解析器、事件循环等底层话题有好奇心的工程师
  • 需要在团队中制定代码风格与协作规范的 Tech Lead
  • 喜欢阅读多作者文集、愿意在一周内补充视野的中高级程序员

Not a good fit for

  • 零基础、还没有写过任何 JavaScript 代码的初学者
  • 希望系统学习语法或查阅 API 的读者,本书不适合当手册使用
  • 只想找具体框架实战教程、需要可直接套用示例的人

Reading tips

  1. 先通读目录挑出最感兴趣的三章,按主题跳跃阅读,本书各章之间并无依赖关系。
  2. 读第 7 章解析器时,建议在本地跟着敲一遍词法分析与语法树遍历,收获远大于纯阅读。
  3. 读到 mixin、构造器、错误处理等章节时,对照自己项目里的现有代码做一次复盘,把结论落成重构清单。
  4. 留意英文原版成书于 2015 年,涉及生态与工具的部分请以当前官方文档为准。

Contents

  1. Preface
  2. Chapter 1 Beautiful Mixins
  3. Class Inheritance
  4. Prototypes
  5. The Mixin Method
  6. Summary
  7. Chapter 2 eval and Domain-Specific Languages
  8. What Is All This About “eval Is Evil”?
  9. History and Interface
  10. Performance
  11. Common Use Cases
  12. Template Compilers
  13. Speed
  14. Mixing Multiple Languages
  15. Dependencies and Scope
  16. Debugging Generated Code
  17. Binary Pattern Matching
  18. Some Final Thoughts
  19. Chapter 3 How to Draw a Bunny
  20. What Is a Rabbit?
  21. What Is a Bunny?
  22. What Does Drawing Have to Do with JavaScript?
  23. Many Forms of Expression — Which One Is Right?
  24. What Does This Mean for Classroom Teaching?
  25. Is This Art? Why Does It Matter?
  26. What Does It Look Like?
  27. What Have I Just Read?
  28. Chapter 4 Too Many Strings, or JavaScript Team Development
  29. Readers Who Understand the Code
  30. There’s No Harm in Writing Code More Plainly
  31. Using Class Inheritance
  32. Style Guides
  33. The Evolution of Code
  34. Chapter 5 Constructor Design: Techniques for Building Harmonious Models
  35. Ghosts: Multiple Instances of the Same Model
  36. Tiny Models Built with Factory Functions
  37. Constructor Identity Crisis
  38. Supporting Extension
  39. Chapter 6 One World, One Language
  40. A Powerful Proposal

FAQ

这本书适合 JavaScript 入门读者吗?
不太适合。书中不系统讲解语法,多数章节默认读者已经能熟练写 JavaScript,并从设计取舍、语言机制等更高层面展开讨论。建议先读完一本入门或进阶教程再来读它。
书里的内容现在会不会过时?
英文原版出版于 2015 年,涉及 Backbone 演进、当时工具链的部分确实有年代感;但 mixin、原型继承、eval 与 DSL、解析器、事件循环、错误处理等主题讨论的是语言本身与工程思想,依然适用。
它是某一本讲 JavaScript 的书的中文版吗?
是的,它是 O'Reilly Media 出版的 Beautiful JavaScript: Leading Programmers Explain How They Think 的简体中文版,由中国电力出版社 2017 年引进,杜春晓、司韦韦翻译。台湾地区另有繁体中文版。
一共多少章、多少篇幅?
简体中文版共 14 章,正文约 155 页,版权页标注字数 198 千字,定价 48 元。篇幅不大,适合当作阶段性补充阅读。
这本书的编者是谁?
编者 Anton Kovalyov(安顿·科瓦诺夫)是 JSHint 的创建者、Third-Party JavaScript 的合著者,曾任职于 Yahoo 与 Medium,长期参与 JavaScript 社区的工具与规范建设。

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.

Top rated in the same category