Chapter 2

Ruby

A spoonful of sugar makes the medicine go down.

Mary Poppins

If you are sampling this book, chances are we have something in common: learning programming languages intrigues us. To me, learning a language is like learning a character. Throughout my career, I’ve experienced scores of languages firsthand. Like any person, each language took on a distinct personality. Java was like having a rich lawyer as a brother. He was fun when he was younger, but now he’s a black hole that sucks away all the joy in a 100-mile radius. Visual Basic was like that bleached-blond cosmetologist. She’s not going to solve global warming, but she’s always good for a haircut and tremendously fun to talk to. Throughout the book, I will compare the languages you will encounter to popular characters. I hope the comparisons will help you unlock a little bit about the character that makes each language special.

Meet Ruby, one of my favorites. She’s sometimes quirky, always beautiful, a little mysterious, and absolutely magical. Think Mary Poppins,[1] the British nanny. At the time, most nannies were like most of the C family of languages—draconian beasts who were mercilessly efficient but about as fun as taking that shot of cod liver oil every night. With a spoonful of sugar, everything changed. Mary Poppins made the household more efficient by making it fun and coaxing every last bit of passion from her charges. Ruby does the same thing and with more syntactic sugar[2] than a spoonful. Matz, Ruby’s creator, doesn’t worry about the efficiency of the language. He optimizes the efficiency of the programmers.