Å·±¦ÓéÀÖ

Jump to ratings and reviews
Rate this book
Rate this book
It’s easy to write correct Ruby code, but to gain the fluency needed to write great Ruby code, you must go beyond syntax and absorb the “Ruby way� of thinking and problem solving. In Eloquent Ruby, Russ Olsen helps you write 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 this language’s elegance and expressiveness. 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 or C#); why Ruby has so many control structures; how to use strings, expressions, and symbols; and what dynamic typing is really good for. Next, the book addresses 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. A part of 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.

448 pages, Paperback

First published January 27, 2011

17 people are currently reading
429 people want to read

About the author

Russ Olsen

9Ìýbooks80Ìýfollowers

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
639 (49%)
4 stars
492 (38%)
3 stars
137 (10%)
2 stars
13 (1%)
1 star
8 (<1%)
Displaying 1 - 30 of 69 reviews
15 reviews
September 15, 2011
Eloquent Ruby takes a ride through 30 topics about Ruby, from how the Ruby community idents code to Metaprogramming and how to publish a Gem to RubyGems.

I really liked the flow of the book, it's not dense at all and it's full of examples. This is the type of books that I like to read: 300-400 pages, easy to start and easy to finish :).

I think it's a great book for someone who has done some ruby before, but who doesn't feel comfortable with the language yet.
I think it might be an excellent companion to any book that focuses on rails, but leaves all the sweet spots of the language aside.
Profile Image for Ieva Gr.
185 reviews33 followers
December 29, 2019
Was it easy to read: Yes!

What I liked about it: How easy to read it was. It was supposed to be a technical book I’ve read for work, but I had a complete blast reading it! I’m utterly amazed how witty and skilful writer the author is. Plus the book was really useful and good at explaining the basics. Before getting to the book I’ve read few online tutorials, watched some Pluralsight courses and I think the book really crossed all the t’s and dotted all the i’s for me.

What I disliked: The chapter about RSpec was a little outdated (e.g. all examples were in should syntax).
Profile Image for Michael.
162 reviews73 followers
April 23, 2011
This book is a true gem! Mostly written for people coming to Ruby from other programming languages, Russ Olsen doesn't dwell on banalities, but instead teaches you good, idiomatic Ruby. The presented material is excellent and the writing is witty and clever. If you are new to programming this is probably not the best book for you, but if you have experience in some other language or "just" want to get more fluent in Ruby, "Eloquent Ruby" is hard to beat.
Profile Image for Joel Oliveira.
26 reviews2 followers
August 16, 2011
Just finished this - the first programming book I've ever read from start to finish. Russ Olsen does an amazing job making the subject interesting and digestible. As I got through the Metaprogramming chapters I really started feeling like I was *getting* it ... like I was leveling up my skills.

Can't wait to put some of these new concepts and tricks into practice.
Profile Image for Stefan Teixeira.
27 reviews5 followers
June 11, 2016
Amazing book about the Ruby language. It covers almost everything about the language in a very concise way. It is great both for beginners and for people who already have experience with Ruby.
5 reviews1 follower
February 12, 2019
If any of my friends asked me if "Eloquent Ruby" was a good way to start their journey with Ruby, I'd rather say "no". This book starts really innocently, with explanations of many subjects commonly considered as "easy". It gives a good insight about Ruby, how ceratain features of both Ruby and Rails (and many more live examples are mentioned as well) work. It also focused in introducing blocks, procs and other Ruby-related subjects.

But starting from somewhere around middle of the book, every new paragraph brings new (at least for me at the time) knowledge related to Ruby, which in my belief is good to know to expand your horizons and have general understanding how things work (like method_missing), but in the same time, introduced to "regular" Rails projects would be a nightmare for even me to debug in few months' time without putting comments above the snippets of code that were put there to define methods dynamically for instance. This feeling may be caused by the fact, that maybe I just haven't encountered any situation that would need implementing features in described way yet - I think I will be able to confront this point of view in the future. Same goes for monkey patching - it's good to know it exist and in case of a fire do some hand patches of failing methods, but lot of sources treat it as a code smell.

In overall, I feel I've learned a bunch of new things, refreshed some knowledge and made the whole Ruby-foundations more solid. I could completely agree with the Author, that this is not a book to be read once and then put on a shelf. Going back to some of the marked chapters would defenitely be helpful and will give many more insights about what's Ruby really about - in fact the book will stay the same, only our knowledge and point of view are the factors that are gonna change :)
Profile Image for Daniel Dao.
99 reviews30 followers
October 13, 2020
Eloquent Ruby is pretty great. It's written in an approachable way that explains some of the fascinating Ruby paradigms (blocks, modules, class / namespace resolution). I'd say it's more of an intermediate level book (i.e. someone should probably have some experience with Ruby) and that beginners won't be able to extrapolate the most from it. Would recommend to someone who's familiar with programming and has seen different usages of Ruby.
Profile Image for Edgar Cheverier.
13 reviews
June 5, 2021
If you already know a programming language, and you just started to learn Ruby or you know a bit of Ruby I think this book is great. On the other hand I think if you don't know any Ruby or you know a lot, it may be not that good.
Profile Image for Oana Sipos.
77 reviews58 followers
Currently reading
August 6, 2016
121. "First, each method should do a single thing—focus on solving a single aspect of the problem. By concentrating on one thing, your methods are not only easier to write, they are also easier to understand.

Second, each method needs to operate at a single conceptual level: Simply put, don’t mix high-level logic with the nitty-gritty details. A method that implements the business logic around, say, currency conversions, should not suddenly veer off into the details of how the various accounts are stored in a database.

Finally, each method needs to have a name that reflects its purpose. Nothing new here; we have all heard endless lectures about picking good method names. The time to listen to all of that haranguing is when you are creating lots of little methods that you are trying to pull together into a functional whole. Done right, the method names guide you through the logic of the code."

130. "So when you say this:
sum = first + second
What you are really saying is:
sum = first.+(second)

The second expression sets the variable sum to the result of calling the + method on first, passing in second as an argument. Other than + being a strange-looking method name (it is, however, a perfectly good Ruby method name), the second expression is a simple assignment involving a method call."

132. "The not operator, along with and, or, ||, and &&, are built in to Ruby, and their behavior is fixed."
Profile Image for Andy.
35 reviews41 followers
January 5, 2021
This book should be called "Ruby: The Bad Parts."
461 reviews14 followers
November 14, 2018
This is a very good book on what is a rather difficult topic. The idea of "eloquence" is broad and opinionated and at first I thought the author was going to be covering very basic stuff that was easy to pick up. Early on there were a lot of "best practices" that it didn't seem like you could even learn Ruby without absorbing at some point. And the (contrived, but of course) example seemed like it might be too broad and vague to hang your hat on.

A lot of tech books are content to rehash basic documentation with contrived examples, and it's not really very helpful. The argument is often "we want the reader to be able to use this as a reference."

But this work manages to take its example (a document storage system) and apply it throughout in a way that, yes, you could jump around or go back to a particular chapter for reference purposes, but it also feels like it builds as you go. By the end, I felt enriched in terms of my under-the-hood understanding of Ruby.

I also feel like Ruby is way too cute and subtle for its own good, but that's not the author's fault. ;-)
Profile Image for Artur.
239 reviews
December 28, 2019
This book is a great introduction to the most foundational and cornerstone aspects of Ruby in the form of 30 chapters each dedicated to its own topic covering practically all the topics that a rubyist should know in the first steps of his career. I like that every chapter includes both a real-world example part along with possible cases of feature misuse and guidance on how to solve them. Even though the version of Ruby described in the book is 1.9 which is quite old by now, it signals the core concepts and conventions of Ruby that are still valid because of their impact and ubiquitousness in the Ruby world. Any discrepancies with the current practices and language behavior are minor and have almost no impact on the relevance of the concepts described.
Profile Image for Anton Antonov.
350 reviews47 followers
August 3, 2024
Not a bad read per se. I've read it when I had a way different opinion about programming style. It's like I was looking for the Ruby language's "Elements of Style" book, which applies to writing in English with style.

"Eloquent Ruby" tries to do that to some extent with its straightforward idea of "Write code that looks like Ruby." It eventually jumps into Metaprogramming, which other books teach way better.

Its final chapters in the "Putting it All Together" part 4, are all redundant and just fodder, in my opinion.

Nowadays, and even back then, I realized that following pragmatic and ever-evolving style guides, such as Bozhidar Batsov's Ruby Style Guide, is more beneficial.

Kudos for Russ Olsen for starting this movement in 2011, though.
4 reviews5 followers
January 23, 2021
I'm an experienced programmer and this is my first book learning Ruby. First of all, this is not an all-in-one syntax handbook. Many language details are omitted from author in order to emphasis some important messages: the flexibility of Ruby compared to other strictly typed languages. That said, this book is suitable for Ruby beginners who have exposures to object oriented programming.
Looking into Ruby on Rails after reading this book, I feel many mysteries starting to make senses.

See for notes.
1 review
December 1, 2018
I think by reading this book I got a different perspective about my Ruby on Rails application. During my 3 years of professional career I had never implemented something using a ruby block, but while reading this book I did implement a custom iterator using ruby blocks. Moreover, this book has given me more confidence for reading out the source code of various gems and libraries.
Profile Image for Xavier Malparty.
29 reviews
June 11, 2021
Very interesting: First time I learn a language not just by its syntax and specificities, but by its philosophy and mindset. All that illustrated by clear examples. Nice!
Not all stars as it might get a little old, still talking about migration from 1.8 to 1.9 while nowadays conferences are all focus on Ruby 3.0+ ;-)
Profile Image for Landon.
21 reviews1 follower
August 30, 2017
This is my favorite Ruby book. It's an in-depth love letter to the cleanliness and elegance of Ruby. Reading this book made me a better Ruby developer. It helped me to understand and appreciate the underlying aesthetic to clean and concise code.
Profile Image for Eric Li.
82 reviews1 follower
July 27, 2020
I enjoy a well-written tech book that dive deep into subjects. It feels like riding a rocket ship knowing your pilot is not a robot but a human who knows what he is doing and cracks joke through the intercom.
I will probably pick up the design patterns by the same author next.
Profile Image for Hinesh Patel.
8 reviews1 follower
March 5, 2019
This book provides a good deep dive into Ruby but is outdated.
Profile Image for Lenin Gangwal.
19 reviews5 followers
Read
July 12, 2020
Survived 2 years as a ruby-dev without really reading this book. Eh, all you need is for and if-else for writing in a typical legacy crud application.
I don't think I will pick it up again.
Profile Image for Jeffrey Dill.
268 reviews3 followers
May 26, 2022
One of the best-written tech books I've ever read. This is an essential book for any professional Ruby developer.
1 review
June 13, 2023
Good book to start but it provides tips to work with ruby not to provides detail of each method
Profile Image for Jay Vercellone.
7 reviews2 followers
October 24, 2023
A must

This book is a must-read for any serious developer using Ruby. You will write better code and avoid lots of headaches.
3 reviews
December 7, 2023
Brilliant book- great for navigating the gap between early/mid intermediate Ruby.
8 reviews
February 15, 2024
Would love an updated version with newer syntax and language features but still an excellent guide with plenty of good tips
Profile Image for Marat Chardymov.
7 reviews1 follower
August 27, 2017
Good book for novices, easy to read, but I'd say too elementary in the beginning
Profile Image for Michael.
193 reviews
April 3, 2013
This book is divided into four parts labeled:

1) The Basics
2) Classes, Modules, and Blocks
3) Metaprogramming
4) Pulling It All Together

Rating them individually I'd give five stars to the first two, three stars to the third & two in the fourth for an overall average, rounded up, of four.

I felt like the first two sections provided an incredible foundation to the syntax of the language. Highly recommended. These sections alone justify the purchase of the book.

The material presented in the metaprogramming section seemed shallow to me (relative to the buzz I've heard/read) although I'm new enough to the language--albeit coming largely from a less mainstream language--that either there is a lot more depth untouched by this book or whatever mainstream language people come to Ruby from must really be handicapped for the examples presented in these chapters to merit the hype Ruby has.

The final section felt rushed. Admittedly it was wrapping things up and "pulling it all together", but aside from the chapter on gems the other topics were covered at a higher level than I would have liked. Though, in fairness each chapter could be a standalone book. I'd have been content to see the book stop after the third part & have the topics in the fourth covered in more depth in a companion volume.

Just my two cents though. YMMV.
Profile Image for Case.
48 reviews15 followers
August 3, 2014
Wow! This book was perfect for me. It is expected that you have programming knowledge and get the general ideas of how to write good code, but need to know how to do it well in Ruby.

I love the layout of each chapter, in that I feel it generally covers well why each feature is useful and how to avoid impaling yourself on the sharp stick of Ruby with said feature.

The writing was entertaining though a bit rough in a few places. It has the feel of a book that has been aggressively edited down to be a readable length, but there are a few places where you come up feeling like there is more to the story that might help. This isn't enough for me to take off a star.

Well done! I'll be recommending this to anyone learning Ruby.
Displaying 1 - 30 of 69 reviews

Can't find what you're looking for?

Get help and learn more about the design.