Learn Ruby with these 10 books and other resources

Finding the best resources when learning any programming language is not always easy. Chad Perrin makes this process easier for experienced and novice programmers interested in learning Ruby. He recommends 10 great Ruby books as well as other resources.

Learning to program, or just learning to program in a new language, can be a challenge if you cannot find the right introductory and reference materials. Some languages make it easier than others, but in a perfect world, you would always have the right introductory and reference materials available.

Fortunately for anyone who wants to learn Ruby, there are a great many learning resources available. The trick is finding them.

Online Ruby documentation

The world is getting better about providing learning materials for programming languages for free, thanks to the efforts of volunteers and vendors. It is increasingly often the case that you can find class, method, and function documentation for language primitives and standard libraries, as in the case of a Web-based collection of documentation for the Ruby language at Ruby-Doc.org. In fact, if you need documentation with examples for any core class in Ruby, the simplest of Google searches will typically lead you directly to documentation on this site. Just enter ruby array into the Google search box, for instance, and the top hit will almost certainly be the array documentation at Ruby-Doc.org.

It is also increasingly common to find documentation at your fingertips on your local system, as long as you have the standard distribution of the language's reference implementation installed. For instance, the ri tool for Ruby can give you information similar to what you would find at Ruby-Doc.org; the following is the output for the command ri Array.to_s:

------------------------------------------------------------- Array#to_s

array.to_s -> string


Returns _self_+.join+.

[ "a", "e", "i", "o" ].to_s #=> "aeio"

Doing a Google search for Ruby tutorial, Ruby introduction, or Ruby howto is likely to return more results than you can use, too. Unfortunately, such options are usually less than ideal; online tutorials typically only barely scratch the surface.

The Ruby community

Language communities can be a great help as well -- as long as your language of choice has a good community. Ruby's community is among the best. In particular, the ruby-talk mailing list is a great place to go for interactive help from fellow Rubyists, though there are several other mailing lists related to the Ruby language and its community. You can find a signup form for the ruby-talk, ruby-core, ruby-doc, and ruby-cvs mailing lists at the Ruby Programming Language Mailing Lists page. The ruby-talk list is the primary list for the community, and there are also newsgroup and Web forum gateways to the list in case email is not your preferred form of participation with an online community.

The Ruby Programming Language Community page also offers information on local user groups that have actual meatspace meetings, an IRC channel, Weblogs about Ruby, conferences around the world, and even a mentoring project that tries to help link up new programmers and experienced programmers in mentoring relationships.

There are other subcommunities as well, such as those particular to specific development frameworks -- including the (in)famous Ruby on Rails Web application framework. There is a Ruby on Rails Community page with links and information for a variety of community resources particular to Rails.

10 great Ruby books

Ultimately, books are often among the most important resources for quick, in-depth introductions to a language. The best books to use for introducing yourself to a given language will depend on the language, and also on the person trying to learn it. While different learning styles can really make it difficult to nail down the perfect lineup of books, it is usually the case that a well-written book will be at least good, if not perfect, as a learning tool. With the right set of books, a little diligence, time, and the tools and inspiration to practice programming in the language, you can work your way up from neophyte to competent coder.

A list of good Ruby books for people new to the language includes:

  • Agile Web Development with Rails by Sam Ruby, Dave Thomas, David Heinemeier Hansson, et al.: A lineup of august personages (including Thomas, one of the Pragmatic Programmers, and Hansson, the inventor of Rails) in the realm of Ruby development in general, and Rails development in particular, makes this a go-to book for those who wish to delve into the realm of Web application development using one of the hottest Web frameworks available. The first edition of this book (which rests on a shelf near the computer where this article was written) was the first, definitive, and canonical text about the Rails Web application framework.
  • Everyday Scripting with Ruby by Brian Marick: This book is oriented toward technically proficient people, though not necessarily toward expert programmers. Despite this, even expert developers may find Marick's simple explanations of idiomatic Ruby programming illuminating. It is relatively low-impact, in that the author's introductions to concepts of Ruby programming (and test-driven development) are engaging and easy to follow without being so elementary as to be useless to anyone beyond the freshest novice. It serves as an excellent introduction to Ruby for anyone with at least some technical chops who needs a book or two as a place to start.
  • Learn to Program by Chris Pine: This is, in essence, the canonical Ruby-based introduction to programming for people who have never written a line of code in their lives. It starts out incredibly simple, and eases the new programmer into the concepts of automating tasks on a computer via the Ruby language.
  • Metaprogramming Ruby by Paolo Perrotta: The most advanced Ruby programming techniques will always be those some true luminary of the language is probably inventing right now, but for an introduction to the heady heights of true Ruby expertise, you could do far worse than this book. Metaprogramming can be defined loosely as writing programs that write or modify programs -- especially themselves. While this may eventually be the only kind of programming we do, for now it is highly advanced stuff, and this book provides a lucid, comprehensible, and eminently practical introduction to such techniques in the Ruby language.
  • Programming Ruby by Dave Thomas, with Chad Fowler and Andy Hunt: Also known as The Pickaxe Book, because of the pickaxe image on its cover, this is generally considered the definitive reference for programming in Ruby. It was the first major Ruby book to be published, and was written and published by the authors of a timeless classic of good programming practice, The Pragmatic Programmer.
  • Ruby Best Practices by Gregory T. Brown: This is no simple explanation of preferred whitespacing, naming, and scope management conventions. Brown uses examples from real, well-written Ruby libraries and applications to demonstrate how the best Ruby programmers think when they write code, and how the reader can approach writing code in Ruby to achieve similarly beautiful, effective results.
  • Ruby in a Nutshell by Yukihiro Matsumoto: Ruby creator Yukihiro Matsumoto, also known affectionately as "Matz" in the Ruby community, wrote this desktop reference for the Ruby language. Books like Programming Ruby and The Ruby Programming Language take a guided tour approach to offering reference material on the language; O'Reilly Media's Nutshell book series takes the approach of organizing information about a technical subject in a manner that is optimized for quickly looking up specific details to refresh the experienced programmer's memory about how specific language constructs work. For those who want this kind of reference book on their desks, the O'Reilly Nutshell series is hard to beat.
  • The Ruby Programming Language by David Flanagan and Yukihiro Matsumoto: This book is decorated with illustrations by legendary -- and now missing -- whimsical Ruby programming master Why the Lucky Stiff. It is exactly what one should expect from a language reference written by its creator, a well-respected programming text author, and a developer who injected a lot of the spirit of fun into the community that flavors it even now, about a year and a half after he vanished from the Internet. Why the Lucky Stiff's cartoon creations have become mascots for the language, and his disappearance inspired a day of remembrance and joyful coding called Whyday.
  • The Ruby Way by Hal Fulton: Organized in the manner of a "cookbook," the real value of this book is not drop-in code snippets or hints about what libraries to use for particular tasks, though these are benefits the book provides. The most important thing this massive tome of Ruby wisdom offers is its demonstration of how to write idiomatic Ruby code that leverages the beauty of its syntactic and semantic model to produce extensible, maintainable, elegant code.
  • Why's (Poignant) Guide to Ruby by Why the Lucky Stiff: As described in the entry for the Pickaxe above, why was a unique individual in the Ruby community, and his contributions pushed the boundaries of people's conventional approaches to programming. It helped us all broaden our perspectives on software development, and helped many of us rediscover or enhance our joy in the art of coding. One of the ways he did this was this digital book, released for free on the Internet, still available from a variety of sources. A Google search for why's poignant guide should provide ample results to get you on your way to discovering this lighthearted introduction to the language. Unfortunately, it seems likely to become less and less relevant to learning the technical details of Ruby programming as the language evolves in years to come, but the delight in the act of programming that it imparts should remain as potent 10 years from now as it is today.
The five Ruby books you should get first

Even focusing on only five books, at least two lists need to be presented to serve the needs of both brand-new programmers and people coming to Ruby from other languages. These lists are numbered in the order in which you should probably get the selected books. As you progress through a list, it is expected that, if your needs begin to diverge from the assumptions about what you may need from a given list, you will evaluate those needs and make changes to the list. As more books are published, some of these selections may even become obsolete, or at least less important than newly published works.

For experienced programmers:

  1. Everyday Scripting with Ruby
  2. Programming Ruby or The Ruby Programming Language
  3. The Ruby Way
  4. Ruby Best Practices
  5. Metaprogramming Ruby

For novice programmers:

  1. Learn to Program
  2. Everyday Scripting with Ruby
  3. Ruby Best Practices
  4. Programming Ruby
  5. The Ruby Way

There is significant overlap in these lists, and not all the titles in my recommendations of great Ruby books are represented. This is because some of the great books about Ruby are too specialized to be particularly suitable to general purpose Ruby programming, or are simply not likely to be suitable to an instructional track for many readers, even if they are wonderful books.

When learning Ruby, you will likely find that the one guiding principle that most helps you progress is simply this: follow your enjoyment of the language. Yukihiro Matsumoto has said that one of the most central motivations in developing the Ruby language is to help make programming enjoyable. With that in mind, it seems likely that if you are not enjoying the use of the Ruby language, you are doing it wrong.

More programming resources on TechRepublic