Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Overview

It’s easy to write “correct” Ruby code. But it’s far harder to gain the fluency needed to write great Ruby code. To do that, you need to go beyond syntax and absorb the “Ruby way” of thinking and problem solving. In Eloquent Ruby, Russ Olsen helps you understand Ruby like true Rubyists do—so you can leverage its immense, surprising power.

Olsen draws on years of experience internalizing the Ruby culture and teaching Ruby to other programmers. He guides you to the “Ah Ha!” moments when it suddenly becomes clear why Ruby works the way it does and how you can take advantage of its unique approach.

Eloquent Ruby starts small, answering tactical questions focused on a single statement, method, test, or bug. You’ll learn how to write code that actually looks like Ruby (not Java); why Ruby has so many control structures; how to use strings, expressions, and symbols; and what dynamic typing is really good for.

Next, Olsen turns to bigger questions related to building methods and classes. You’ll discover why Ruby classes contain so many tiny methods, when to use operator overloading, and when to avoid it. Olsen explains how to write Ruby code that writes its own code—and why you’ll want to. He concludes with powerful project-level features and techniques ranging from gems to Domain Specific Languages.

The newest book in the renowned Addison-Wesley Professional Ruby Series, Eloquent Ruby will help you “put on your Ruby-colored glasses” and get results that make you a true believer.

Subscriber Reviews

Average Rating: 4.833333333333333 out of 5 rating Based on 18 Ratings

"Must read" - by Nithin on 28-FEB-2011
Reviewer Rating: 1 star rating2 star rating3 star rating4 star rating5 star rating
If you are new to Ruby programming, Eloquent Ruby should be the book you read right after you finish your introductory Ruby book. It’s not a beginner’s tutorial, but with a little background on Ruby, it would be easy to follow.

This is one of the better programming books I’ve read. It has plenty of short and clear example code snippets, a very conversational and humorous writing style and most importantly, covers exactly the kind of topics a newbie should understand about Ruby.

The book is divided into 4 parts – (1) The Basics, (2) Classes, Modules and Blocks, (3) Metaprogramming (4) Pulling It All Together.

The firsts section covers the basic Ruby idioms in a way that you wouldn’t normally get to read in most books. It has chapters like “Choosing the Right Control Structure”, “Write Specs”, “Embrace Dynamic Typing”.

The second section — the most useful one, in my opinion — covers classes, modules and blocks with chapters like “Use Class Instance Variables”, “Use Blocks to Iterate” and “Use Modules as Name Spaces”. This section does an excellent job of explaining how to effectively use blocks, which are probably Ruby’s most useful feature.

The third section talks quite a lot about using, and of not misusing, the powerful method_missing method. Other Ruby metaprogramming topics such as monkey-patching are also covered.

The final section talks about one of Ruby’s greatest strengths — building DSLs — and also about creating and packaging gems. The book wraps up with a quick note on the the available ruby implementations.

At the end of each chapter there is a section “In the Wild” where the author points to real world code relevant to that chapter. Knowing where to look for real world examples will be especially useful for newbies who haven’t read a lot of other people’s code.

Another useful section in each chapter is “Staying Out of Trouble”, where the author explains the common pitfalls associated with the topic being discussed.

The examples that are used in the book make it extremely easy to understand. I often find books choosing overly elaborate examples and thereby distracting readers away from the language idiom being discussed. Eloquent Ruby doesn’t have that problem. The author starts with a simple Document class and uses the same example throughout the book, making it easy to focus on the idiom being discussed.

There are no real negatives I can point out, except for the slightly outdated chapter on packaging gems. However, I was reading the Safari’s Rough Cuts edition of the book, and it’s a work in progress, so it might get updated soon enough.

This book is a must read if you are a beginner to intermediate level Ruby programmer. It teaches the Ruby way of writing code, and answers many of the questions that one might have on the effective use of Ruby idioms.

Report as Inappropriate

Table of Contents

 Index