Beginning Ruby Book: Learn Ruby Programming Inside
Author: ceefour | Filed under: Beginner, Books, News, Opinions, Plugins, Praises, Rails, Reviews, RubyIf you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

I was so excited when I first heard Peter Cooper (from Ruby Inside) would write a book… on Ruby! So, yes, I did have some very high expectations and I would say Peter’s writing blew me away.
<br />Beginning Ruby: From Novice to Professional covers a broad range of topics, from basics of the language and dynamic object-oriented programming concepts, to the use of reusable libraries with particular emphasis on emerging Internet technologies, such as XML, RSS feeds, and distributed programming. Beginner programmers will appreciate its newbie-friendly language for describing general programming concepts, as usual with Apress‘ Beginning books. Readers coming from another programming language will enjoy its comprehensive primer on Ruby’s distinctive strengths as a highly dynamic language.
The book spans 14 chapters, 3 appendixes, with more than 600 pages (hint: thicker than your laptop), and the first unique bonus is that the foreword is “written” (actually, drawn) by whytheluckystiff.* Alright, on to the real review… (which does look more like a glorified table of contents)
Chapter 1 begins not with the history of Ruby, which is so much of a blessing! Peter guides you step-by-step to installing Ruby in most popular platforms (that is, Windows, Mac OS X, and Linux) and also references to other platforms. JRuby is also mentioned, but I think it should be a first-class citizen in a future edition of this book. It is a very quick read as the next chapter gives you the more interesting content: getting started with Ruby quickly.
In Chapter 2, Peter shows the reader how Ruby is easy to learn and English-like by demonstrating Ruby’s clear and concise syntax even in rather complicated statements. There are lots of general programming concepts here, and Peter explains them very well, even complex concepts such as classes and objects. An overview of variables, methods, and method arguments is given.
Chapter 3 gives a proper programming language primer in variables, expressions, constants, strings, and math calculations. Of course, Peter makes this interesting because he does this all in Ruby style. Essential for readers without prior experience in Ruby programming style. String manipulation, regular expressions, flow control (if, unless, while, etc.), blocks, even some date/time functions. I’d suggest experienced programmers wanting to learn Ruby quickly to jump right to Chapter 3 to get a feel of how Ruby really is like. I especially like the fact that Peter preincludes the most important regular expression semantics so the beginner reader doesn’t have to look for other references just to build a pattern. (a more thorough regular expression quick reference is also available in Appendix B.)
In Chapter 4 Peter tours the reader using a more interesting example application, a text analyzer. Many string manipulation functions are discussed here, including of course regular expressions. I’d really love if Peter gave a note here explaining the difference between characters and bytes, which he didn’t, since it probably doesn’t matter to most people. But I wonder what would happen if somebody using a multibyte encoding (such as a Japanese or Chinese) attempts the examples Peter gave using his own texts.
(On a note, he does touch this Unicode/encoding issues a bit in Chapter 11.)
Chapter 5 is mostly what Chapter 1 would have been in traditional books. A quick rundown of Ruby history and online resources, including forums, is given. It probably bores many people initially but will be very handy later when you’re searching for a solution to your own problems.
You will be taken deeper into the Ruby language in Chapter 6, discussing classes, objects, and modules. Java and .NET folks will be especially entertained here, and first-time learners would probably need some time to grasp these concepts, which Peter describes in a beginner-friendly way. In addition to standard object-oriented techniques like inheritance, encapsulation and reflection, Ruby-specific enhancements are also discussed, including of course our mighty mix-ins. A short but interesting text-based adventure game is given as a working example, pretty neat!
The next chapter teaches you how to assemble your Ruby classes into a whole project, and how to install third-party libraries with RubyGems. Some of the interesting gems Peter showcased in this chapter (like Hpricot) are discussed more thoroughly in later chapters.
Chapter 8 explains essential developer skills, like producing automated (RDoc) documentation, exception handling, and debugging. By reading this, you’ll know how to debug your apps using Ruby’s built-in debugger, perform unit testing using Test::Unit, and tweaking your app’s performance using benchmarking and profiling. These are (especially testing) are very important techniques that developers can hardly live without.
Chapter 9 starts by describing file and directory management functions and how to read/write CSV and YAML files. The second half of the chapter is devoted to connecting to relational (SQL) databases such as MySQL and SQLite, and also provides a quick overview of common SQL statements.
How to deploy Ruby applications and libraries is the focus of Chapter 10. You’ll be able to build your own gems, and also to write server-based programs using the CGI, HTTP, XML-RPC, or DRb (distributed Ruby) protocol.
Want to learn Ruby’s cool tricks? You’ll get ‘em in Chapter 11, with dynamic evaluation, forking, Windows API interfacing, multithreading, C language inlining, and Unicode support. Ruby still has lots more tricks and this chapter provides good introduction to the most useful ones.
The main Ruby project of the book is given in Chapter 12: A bot application you can have a chat with. (the word ‘cool’ itself isn’t as cool as this one.) It reviews many of the concepts introduced before, including string manipulation, unit testing, file manipulation, data structures, control flow, OOP (object-oriented programming), and creating a web-based version of the application.
The final chapters of the book deal with building online Internet applications with Ruby, and Chapter 13 righteously starts it by introducing Ruby on Rails. Rails is a framework for developing web-based applications, which compared to other frameworks is far easier to use (yet very complex under the hood.) This chapter gives a tour to the broad aspects of a Rails application, from the models, views, and controllers, to Active Record, routing, sessions, and the Rails testing framework.
Using Ruby with Internet technologies such as HTTP, URI, XML, HTML, RSS feeds, and e-mail is covered in Chapter 14. No dependency on Rails here, although it demonstrates the use of cool gems like Hpricot. The following chapter explains the Ruby way of doing low-level network operations using TCP/IP, ICMP (ping), DNS resolving, UDP, and TCP.
The final chapter lists a bunch of useful libraries and gems, for example iconv, logger, RedCloth, and zlib. For each library, a summary description and instructions on how to install and use it, along with several examples, is provided. I definitely want more stuff covered here, but this book is already thick enough. I think it’d be great if Peter would (in the next edition) dedicate several pages listing many more special-purpose Ruby libraries in a simple format with relevant URLs.
The last pages contain three appendixes and a thorough index. The first two appendixes re-reviews the Ruby programming language constructs and semantics, which are always handy for a quick reference. The third appendix lists useful online resources, such as web sites, blogs, forums, and articles that will expand your knowledge in Ruby (and related technologies such as Rails) even more.
Although the book is quite thick, it’s a very entertaining read and definitely useful. When I said thick, I was so overstating, since the book’s physical dimensions and price aren’t even close to justifying the amount of quality content that Peter Cooper had put in. Whether you’re starting to learn programming or considering Ruby as your next programming language, I heartily recommend Apress’ Beginning Ruby: From Novice to Professional as the first book on Ruby you should have.
* If you like _why’s drawing in this book’s foreword, I suggest you to readsee his Poignant’s Guide to Ruby which is full of exciting cartoons.
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.