There may be no better way to learn how to program than by dissecting real, representative examples written in your language of choice. Ruby by Example analyzes a series of Ruby scripts, examining how the code works, explaining the concepts it illustrates, and showing how to modify it to suit your needs. Baird's examples demonstrate key features of the language (such as inheritance, encapsulation, higher-order functions, and recursion), while simultaneously solving difficult problems (such as validating XML, creating a bilingual program, and creating command-line interfaces). Each chapter builds upon the previous, and each key concept is highlighted in the margin to make it easier for you to navigate the book.

You'll learn how to:

Use the interactive Ruby shell (irb) to learn key features of the language

Extend Ruby using RubyGems, the Ruby package manager

Create numerical utilities, as well as utilities that process and analyze HTML/XML

Implement purely functional and metaprogramming techniques to save time and effort

Optimize, profile, and test your code to make sure that it not only does its job, but does it well

Create web applications using Rails

Ruby is the fastest growing programming language today, and for good reason: Its elegant syntax and readable code make for prolific and happy programmers. But it can be difficult to understand and implement without a little help. Ruby by Example shows you how to take advantage of Ruby as you explore Ruby's fundamental concepts in action.

Kevin C. Baird

Kevin C. Baird received his Ph.D. from the State University of New York at Buffalo. He originally wrote his dissertation in Python but rewrote the project after discovering Ruby, and he hasn't looked back since. He has presented at RubyConf and written articles for Linux Journal, Music & Computers magazine, and the New Interfaces for Musical Expression conference proceedings.

By all means, this is a new approach to programming books, and for he most part it works. I read through the first few chapters picking up Ruby wisdom right and left but in later chapters I lost interest in the examples (but not the book).

"Ruby by Example, Concepts and Code" teaches the Ruby language through immersion in examples.

The book begins with a brief introduction to Ruby and the interactive Ruby shell (which allows typing in Ruby code and immediately seeing the results).

The 45 examples that follow are carefully crafted to introduce new language features. A typical example includes these sections:

* The Code

* How It Works

* Running the Script

* The Results

* Hacking the Script

The reader is tempted to open up the examples in an editor, run them and tinker with them.

There is a focus on programming paradigms (or styles). The three main types covered are: imperative, object-oriented and functional. The imperative style "tells computers: Do this, then do that, then do this next thing." "Object-oriented languages define objects (types of things) that know how to perform methods." "Functional languages treat programming problems like mathematical relationships" and allow handling of functions and blocks of codes as if they were objects themselves. Ruby has strengths in all three of these areas, but this book offers more coverage of the functional paradigm than you might see elsewhere.

The examples advance in scope and complexity and cover practical topics like HTML and XML handling, CGI programming (which is a simple technique to make programmable web pages) and finally a sample Ruby on Rails web application.

An appendix compares and contrasts Ruby to several other languages (C, Haskell, Java, Lisp, Perl, PHP, Python and Smalltalk). For each language, the author gives some history, the particular focus or strengths of that language, and how Ruby was inspired by or shares some of the best features of each.

Baird sees Ruby's greatest strengths as "readability, a high level of abstraction (and great ease in extending that abstraction even higher), internal consistency and conceptual elegance."

The book is designed to be accessible to a beginning programmer, but would be challenging (in a good way).

Programmers with experience in another language or with some Ruby experience would strongly benefit from reading "Ruby by Example", even if they have read another tutorial book or started working with Rails applications.