Author: Peter J. Jones
Over the festive season IProgrammer asks its reviewers to recommend books that are worth a second look in case you missed them. Alex Armstrong nominated one of the most enjoyable books on Ruby.
We all want to write effective Ruby so does this book help?
The answer depends what you mean by "effective". This book, and others in the same series that I've read, seems to take the remit to be explaining some of the darker corners of whatever language the book deals with. This might not be what you think of when you think of writing effective Ruby. There is an argument that really the best way to write any language effectively is to steer well clear of exactly these dark corners. You should write code that is clear and simple and if you do this then you are unlikely to encounter any of the 48 "problems" outlined in this book.
However.... there is a huge fascination in delving into the darker corners of a language. Why? The answer is obvious. It is a way of finding out how much you know and expanding your knowledge at the same time. Put another way - it can be both fun and instructive.
Chapter 1 starts off with some general topics. What is true - as in the value true and it turns out everything but 0. Dealing with null objects, cryptic "Perlisms", constants and runtime warnings are the other topics. This first chapter sets the scene and, if you are like me, you start to thing about Ruby's approach to doing things in an obvious way - not so obvious sometimes.
Next we move on to something that most programmer find difficult - Classes, Object and Modules. This digs fairly deep into the way Ruby uses classes - which are really prototype objects. It explains how modules differ from classes and why Ruby's inheritance isn't really multiple inheritance.
Chapter 3 is about collections which isn't exactly core language but it is core from the point of view of usage. This is more in the spirit of how best to do things rather than strange language quirks. It sets forth ways you should do things to get best performance or best code.
The next chapter is exceptional - no really, its about exceptions. My guess is that everyone knows what an exception is and few know how to use it. This is a discussion of how to handle exceptions and its worth reading.
From this point on the book moves a bit off topic away from language details and even the core libraries into slightly more general topics. The first is metaprogramming which Ruby is very good at. This is good but you need to remember that there are whole books devoted to Ruby and metaprogramming so it isn't going very deep. Chapter 6 is on testing and this is just a Ruby specific unit testing discussion - still worth reatind. Chapter 7 moves on to tools and libraries - documentation Gem dependencies and so on. Chapter 8 is about memory management and performance - garbage collection, Finalizers, profiling and so on.
This brings the book to a close.
Overall the book is well written in a gentle and easy-to-read style.
This isn't so much a book about writing effective Ruby code as understanding Ruby and its environment better. It is full of interesting discussion of Ruby's sometimes strange ways of doing things and about facilities that you might have over looked. I don't think that this will improve your Ruby style much, but it is an enjoyable read if you are reasonably good at Ruby.
It isn't an essential book, but you are missing some fun if you don't read it to find out how much you really know about Ruby.
|Last Updated ( Wednesday, 28 December 2016 )|