Eloquent Ruby (US | UK | IT) is a book about the Ruby programming language that focuses on Ruby programming style by teaching you how to write your code as a real Rubyist.
Be prepared, this is an unconventional Ruby book. To use the author's words:
This is a book about making that final leap, about absorbing the Ruby programming culture, about becoming truly fluent in Ruby. You need to absorb the cultural part of Ruby, to see how real Rubyists use the language to solve problems.
Learning Ruby is not difficult; starting to think in Ruby and becoming a Rubyist is the real challenge.
My two cents
Eloquent Ruby is a very lightweight and pleasant read. The colloquial tone is friendly and engrossing. The book has plenty of code snippets and it requires only a few days to read it from start to end.
Aside from being an excellent resource to help you think Ruby and program in the Ruby way, this book constantly adopts a practical approach providing tons of examples to read. Every chapter ends with an In the Wild section containing examples extracted from real Ruby libraries, and a Wrapping up section that helps you fix the concepts in mind.
I appreciated the focus on tests and the RSpec chapter. Most of the examples are verified by tests, and the tests are also available in the book.
I found the Regular Expression chapter pretty boring and misplaced. I would have left the regexp and the RubyGems sections outside the book. Additionally, a wider usage of Ruby 1.9 over Ruby 1.8 in the examples would be preferable, in order to discourage the adoption of Ruby 1.8.
Audience
This book assumes that you have a basic knowledge of the Ruby language. You don't need to be a Ruby master, but some advanced sections such as Metaprogramming and DSL may require you to stop for a moment and refresh or improve your specific knowledge of Ruby on that topic.
If you are a beginner-to-intermediate level Ruby programmer, this book is a must-read that's likely to help you improve your Ruby skills and write code in the Ruby way. Don't expect this book to explain to you the basic details of Ruby or its syntax; this is outside the scope of this publication. There are plenty of commented examples, but if you want to learn about a specific Ruby feature make sure you keep a reference like Programming Ruby or The Ruby Way handy.
If you are completely new to Ruby, I don't recommend starting with this. Approach the language by reading a "programming with Ruby" book, then read Eloquent Ruby to learn how to program in the Ruby way.
If you are a Ruby expert and you have been writing Ruby for the last 5 years, don't be too self-confident. I'm quite sure the book will be able to provide you some valuable advice.
Be ready to read printed source code: this book is full of Ruby code. At least 50% of the pages contain code, making this book a valuable practical reference.
Structure
The book is divided into 4 parts. Each part is divided into chapters. The book counts 31 chapters and about 400 pages.
- The Basics
- Classes, Modules, and Blocks
- Metaprogramming
- Pulling It All Together
The first part covers some basic Ruby features in a way you normally won't read in any other Ruby reference. Ah, if I only had the Symbol chapter available when I started learning Ruby!
The second part covers Classes, Modules and Blocks and it explains how to use modules successfully, how to deal with inheritance, equality and operators. This is by far my most favorite section.
| The third part is about Metaprogramming. Whilst the name of the section is technically correct, it can be misleading. If you are looking for a complete Ruby and Metaprogramming course, check out Metaprogramming Ruby (US | UK). This section covers common Ruby metaprogramming topics such as hooks, method_missing (a must read!) and monkey patching. |
The fourth part wraps several topics all together and talks about creating and implementing a DSL in Ruby.
| The book ends with a rich list of books about Ruby and programming in general. The list contains amazing Ruby titles like Ruby Best Practices (US | UK) or The Ruby Way Second Edition (US | UK), as well programming masterpieces like The Elements of Programming Style (US | UK). If you are looking for some inspiration about your next reading, you might probably find some there. |