Metaprogramming Ruby
Author: Paolo Perrotta
Publisher: Pragmatic Bookshelf, 2010
Pages: 240
ISBN: 978-1934356470
Aimed at: Ruby programmers
Rating: 5
Pros: Imparts a deep understanding of Ruby
Cons: Idiosyncratic tutorial format; a bit too enthusiastic
Reviewed by: Ian Elliot


If you program in Ruby buy a copy of this book.

Now for the reasons why Ian Elliot has chosen it as one of 2010's best books.


You will often hear Ruby programmers say that Ruby is special - this book explains what makes it special and how to make use of these special abilities. It has a strange style that you need to be warned about. The entire book takes the form of a tutorial between a master programmer called Bill and his increasingly skilled assistant, i.e. you. The task is to build some software for a remarkably knowledgeable boss figure.

Unlike most attempts at this method of presenting technical information, it work! It is sufficiently well done for it to be a help in explaining some fairly complicated ideas. Even so there were times when I really would have liked a quick simple and direct explanation of what is going on. There are plenty of summaries and overviews but these are generally placed a page or two ahead of the main narative.

Metaprogramming has long been regarded as dangerous. It is easier to create a metaprogramming mess than it is to create something easy to understand, easy to debug and modify. Most of the time the ideas and techniques are introduced with a correct degree of caution about the impact of metaprogramming on the system as a whole. However, there are moments when you really should worry about letting this particular genie out of the bottle. 

The first section of the book works its way though the various standard metaprogramming techniques. Each chapter is given the name of a day of the week and the idea is that it takes you through what was necessary to implement an application. Monday introduces the Ruby object model and provides the foundation that a lot of what follows is built on. Tuesday is all about methods - how Ruby works out which method to call and in what context. Here we meet one of the main tools in the metaprogramming toolkit - missing methods. Wednesday is all about blocks - which is a very Ruby idea. However, you do end up seeing blocks as a much more integral part of the language than they seem when you are first introduced to them. The example used is of a simple Domain Specific Language (DSL) and if you have always thought that DSL were a waste of time be prepared to think again. Thursday is also about Class and how the type system works in Ruby. Friday is hardcore metaprogramming as we finally get to code that writes code - scary stuff made to seem very reasonable.

The second part of the book is about ActiveRecord, which is a core Ruby system that makes heavy use of metaprogramming. Three chapters take you on a tour of ActiveRecord and at the end you will know how it works, know how to use it and write similar code.

The Appendixes are far more useful than you find in most books. The first goes over common Ruby idioms and not just metaprogramming idioms. The second is an introduction and advocate of DSLs - if you haven't encountered the ideas before then this is the place to start. The final appendix is a collection of "spells" - small patterns of metaprogramming use. All really useful.

If I have to find a fault with the book then its that it is a bit too enthusiastic about Ruby. If you are a Ruby fan then you will simply agree but if you are trying to see what the fuss is about then it could just put you off. It would have been better to tone it down just a touch.

This is a book that will take you from a Ruby novice to an expert, especially if you have migrated to Ruby from another language and are still using it as if it was another language. Even if you don't want to go too deeply into metaprogramming and don't want to actually make use of these "dangerous" techniques the book will impart enough deep understanding of they way Ruby works and its philosophy for you to be a better Ruby programmer after reading it.

Not for the complete beginner but for just about every other Ruby programmer - highly recommended.


Artificial Intelligence, Machine Learning, and Deep Learning (Mercury Learning)

Author: Oswald Campesato
Publisher: Mercury Learning
Date: February 2020
Pages: 300
ISBN: 978-1683924678
Print: 1683924673
Kindle: B084P1K9YP
Audience: Developers interested in machine learning
Rating: 4
Reviewer: Mike James

Another AI/ML book - is there room for another one?

Access 2019 Bible

Author: Michael Alexander and Dick Kusleika
Publisher: Wiley
Pages: 1136
ISBN: 978-1119514756
Print: 1119514754
Kindle: B07J1WJ1ZK
Audience: Access users and developers
Rating: 4.7
Reviewer: Kay Ewbank

This brick of a book has been updated for Access 2019, and while it isn't specifically aimed at deve [ ... ]

More Reviews

Last Updated ( Tuesday, 28 December 2010 )