The Ruby Programming Language

David Flanagan, Yukihiro Matsumoto

出版时间

2008-01-01

ISBN

9780596516178

评分

★★★★★
书籍介绍
Ruby has gained some attention through the popular Ruby on Rails web development framework, but the language alone is worthy of more consideration -- a lot more. This book offers a definition explanation of this powerful and extremely flexible language, which draws inspiration from Lisp, Smalltalk and Perl, but uses a grammar that's easy for C and Java programmers to learn. With The Ruby Programming Language, you will quickly learn your way around versions 1.8 and 1.9, and discover why this pure object-oriented language is also suitable for procedural and functional programming styles. You'll learn Ruby's lexical structure, primary expressions, conditionals, syntax, classes, the data it manipulates, and more. Ruby blurs the distinction between language and platform, so this book includes a tour of the core Ruby API. But the primary subject is the language itself, including: * Ruby's lexical structure including basic issues like character set, case sensitivity and reserved words * Numbers, strings, ranges, arrays, and other data that Ruby programs can manipulate, plus basic features of all Ruby objects * Primary expressions in Ruby -- literals, variable references, method invocations and assignments * Conditionals, loops (including blocks and iterator methods), exceptions and other Ruby expressions * Ruby's method definition and invocation syntax, and the invokeable objects known as procs and lambdas * An explanation of closures in Ruby and an exploration of functional programming techniques * Classes and modules in Ruby, inheritance, method visibility, mixing modules and the method name resolution algorithm * Ruby APIs that allow a program to inspect and manipulate itself, and metaprogramming techniques that use the APIs to extend Ruby's syntax for easier programming * A quick tutorial of the Ruby platform -- the most important classes and methods, text processing, numeric computation, collections, input/output, networking and threads The Ruby Programming Language also covers the top-level Ruby programming environment, including global variables and functions, command-line arguments supported by the Ruby interpreter, and Ruby's security mechanism. If you're an experienced programmer who wants a look at this language in depth, this easy-to-follow guide is invaluable.
AI导读
核心看点
  • Ruby之父松本行弘亲自执笔,权威解读语言设计哲学。
  • 系统讲解Ruby语法、对象模型及元编程等核心特性。
  • 被誉为Ruby版K&R,适合有编程经验的开发者深入研读。
适合谁读
  • 具备其他编程语言基础,希望深入理解Ruby底层机制的开发者。
  • 对函数式、过程式及面向对象编程风格感兴趣的程序员。
  • 不满足于表面应用,渴望探究Ruby语言设计初衷的技术人员。
读前提醒
  • 本书内容详实且理论性强,不适合零基础新手作为第一本入门书。
  • 建议结合实践阅读,部分高级特性如元编程需反复琢磨才能领悟。
  • 若英文基础良好,强烈建议阅读原版,译文可能存在生涩之处。
读者共识
  • 内容极其权威且细致,完美展现了Ruby世界的完整面貌。
  • 相比其他教程,本书语法思路清晰,框架结构完备精美。
  • 虽被赞为经典,但部分读者认为内容过于深奥,阅读体验较累。

本导读基于书籍简介、目录、原文摘录、短评和书评生成,不等同于全文精读。

精彩摘录
  • "在 Ruby 1.9 中,Symbol 类定义了 === ,当其右操作数和左操作数是同一个符号对象时,或者当其右侧操作数是一个持有和左侧符号对象相同文本的字符串时,该操作符返回 true。"
  • "在一个被冻结对象上调用 dup 方法将返回一个未被冻结的副本。"
  • "and、or 及 not 操作符分别是 &&、|| 及 ! 的低优先级版本,使用这些操作符的理由之一是,它们的名字是英文单词,这将使你的代码易于阅读。 另一个理由就是它们的优先级比赋值操作符更低,这意味着你可以编写下面的布尔表达式,不断的对变量赋值,直到遇见一个假植。"
  • "你需要注意的是,and 和 or 的优先级相同 (not 的优先级稍高一点)。因为 and 和 or 具有同样的优先级,而 && 和 || 具有不同的优先级,所以下面两个表达式的结果不同:"
  • "Proc 类定义了 == 方法来判定两个 Proc 对象是否相等。不过,要记住两个 proc 或 lambda 拥有同样的代码并不意味着它们是相等的:"
  • "只有当一个 Proc 对象是另一个 Proc 对象的克隆(clone)或复制品(duplicate)时, == 方法才返回 true:"
  • "这样,在 lambda 中的 return 语句仅仅从 lambda 自身返回,而不会从产生 lambda 的方法中返回"
  • "调用 proc 使用的是 yield 语义,而调用 lambda 使用的是 invocation 语义 proc 对参数处理的灵活性:可以安静的抛弃多余参数,将 nil 赋给遗漏的参数,甚至可以拆开数组。lambda在这方面就没有那么灵活了,跟方法一样,我们必须用与声明时同样多的参数对它进行调用"
作者简介
David Flanagan is a computer programmer who spends most of his time writing about JavaScript and Java. His books with O'Reilly include Java in a Nutshell, Java Examples in a Nutshell, Java Foundation Classes in a Nutshell, JavaScript: The Definitive Guide, and JavaScript Pocket Reference. David has a degree in computer science and engineering from the Massachusetts Institute of Technology. He lives with his wife and children in the U.S. Pacific Northwest bewteen the cities of Seattle, Washington and Vancouver, British Columbia. David has a blog at www.davidflanagan.com. Yukihiro Matsumoto ("Matz"), the creator of Ruby, is a professional programmer who worked for the Japanese open source company, netlab.jp. Matz is also known as one of the open source evangelists in Japan. He's released several open source products, including cmail, the emacs-based mail user agent, written entirely in emacs lisp. Ruby is his first piece of software that has become known outside of Japan.
用户评论
看了我足足三个月啊
才发现,这本书的作者也是 Java In a Nutshell 的作者,这圈真小……
非常不错, 可以作为入门的书籍,不过读的时候要认真一点, 松本自己讲解ruby确实很到位:所谓到位 不是说涉及了多深的内容, 而是 非常完美的把整个ruby世界都展现出来了, 尤其对DSL的例子恰到好处, 自己的语言果然烂熟于胸。 “由本书的作者,亲自为你讲解”, 看到这本书,忍不住想起来大学里 某个老师的经典语录 也顺便感谢他给了我大学里的最高分数。
闲来无事学学奇技淫巧。
讲的很全面,适合快速学习用
翻了一遍,用到了再细看。Ruby 比Python复杂得多。
太尼玛吊了...Matz...
非常好的入门书,每个点都讲得非常清楚
Still on the way, 先来Mark一下. 好性感的语言!
一个java大牛和ruby作者一起写的,事无巨细,用到用不到的都写的很多,我竟然看完了
收藏