all repos — h3rald @ 6ed04d62656d222df819ecfd406a5afb3166d316

The sources of https://h3rald.com

content/articles/hlrb-review.textile

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
----- 
permalink: hlrb-review
filters_pre: 
- redcloth
title: "Book Review: Humble Little Ruby Book"
comments: []

date: 2007-10-03 05:53:00 +02:00
tags: 
- ruby
- review
- books
type: article
toc: true
-----
After reading the very first paragraph of Mr. Neighborly's "Humble Little Ruby Book":http://www.humblelittlerubybook.com/ (HLRB for short, from now on) it was very clear to me that it was going to be quite an unconventional read:

<blockquote>
"Yes, there is a Chapter 0.  There is a little bit of introductory stuff we need to talk about before 
we set you loose on Ruby.  You wouldn't want to get psyched about a new gadget, get it home, 
and then figure out you need batteries, a grapefruit, and the ability to speak three  languages to 
even open the box would you?"
</blockquote>

That reminded me immediately of "Why's Poignant Guide to Ruby":http://poignantguide.net/ruby/. without a doubt. I don't know how it is possible that two witty, crazy, and very inventive guys grew fond of the same programming language. Anyhow, to reassure a few of you, you won't find any foxes or chunky bacon cartoons in HLRB, just some very well made (although still pretty unconventional) diagrams like this one:

!/files/hlrb_diagram.png!

Got the picture? Good. Let's move on...h3. Chapter 0: What'chu talkin' 'bout, mister? 

Chapter 0 is like an introduction to the book _and_ a place to put all the boring stuff you have to talk about in a book about a programming language: 

* What is Ruby?
* Installation procedure (on Windows, Mac OS X and Linux)
* Hello, World!

Yes, you can skip this one safely without losing too much, unless of course you still need to install Ruby on your machine.

h3. Chapter 1: Welcome to Ruby.  

<blockquote>
"This  section  aims  to  introduce  the  syntactic  sugar  and  linguistic  misfortunes  of  Ruby  in  the 
quickest manner that will still allow  for a full  education on the subject."
</blockquote>

As the first two lines of this chapter say, it's time to learn the basics of Ruby. You'll be quickly guided through strings, numbers, collections and variables. Every section with tons of code examples for your to play with. You won't find a full list of all the 876 methods of the String class, but you'll certainly learn the 10 most common ones at least (numbers are random, so no, don't count them). 
Sure, yes, right, whatever... _if you really want_ you can skip this chapter too, but if you are already a Ruby Guru there's probably no need for you to read books about Ruby, right? Beginners need to read this chapter. It's compulsory, really, and pretty enjoyable, too.

h3. Chapter 2: Break it down now!

Or "learn how to segment your code" using methods, and... blocks & @Proc@ objects! Gosh. Our poor newbies will probably have a heart attack if they never heard about blocks and closures before. I almost got scared myself, because this is normally regarded as a pretty tough topic. Despite, at page 25 of the book you'll have to face your fears and dive into it. You'll survive, anyway. 

*Purist Warning:* Please be aware that sometimes the author may decide to use certain terms and construct which may not sound 100% right to your ears. Just move on, beginners will understand more things like _"Think of Proc objects as blocks that are pushed into variables."_ than anything else, guaranteed.

After this section you'll finally be introduced to Ruby classes. Now, this can piss someone off, no doubt. Ruby is a _fully OO language_, so people _must_ learn about classes before anything else. I must admit I was a bit confused by the ordering of the topics at first, but if someone comes from a non-OO background he'll probably find this particular order more suitable. 
This section will cover class and object basics in Ruby like defining classes, instantiating objects, access control, methods, attributes, scope, duck typing. Finally, you'll briefly look into modules as well.

h3. Chapter 3: Hustle and flow (control)

Finally, the author will deal with flow control. So things like @if@, @case@, conditional operators, loops and statement modifiers. In my opinion this section is truly excellent: it introduces all the control structures in a very simple and crystal clear way, often using flowcharts. A great chance even for absolute beginners to understand these basic but powerful concepts.
Towards the end of the chapter, you'll also learn how exceptions work: a clever way to tell people "you have to learn how to use exceptions from the very beginning". Really nicely done.

h3. Chapter 4: The system beneath...

Here comes the juicy stuff. Up to now you learnt the usual boring things you need to know when learning a new programming language, now finally you learn how to do _real things_. The chapter is full of complete and meaningful code snippets which will answer nearly all the questions you may have (at this time):

* How do I read and write to a file?
* How do I handle threads and processes?
* How do command-line parameters and environment variables work?
* How can I perform specific Windows-only operations, like reading and writing to the Registry? What about OLE automation?

Some of the big books out there will not spend too much time talking about Windows-only libraries, but I found HLRB gives quite a comprehensive introduction about them.

h3. Chapter 5: Looking beyond home

More juicy stuff. If you are looking for a tutorial to learn the basics about networking, from from sockets to FTP to POP and web services, look no further: this chapter does a very remarkable job introducing various network-related libraries, with the usual well written code examples.
If that's still not enough, you'll also have a chance to explore the wonderful world of distributed Ruby and of databases. Granted, this chapter won't tell you about the 1567 methods available in ActiveRecord (buy a copy of "Agile Web Development with Rails":http://www.pragmaticprogrammer.com/title/rails/ for this), but will tell you enough to get started.


h3. Chapter 6: It's a Library!

The final chapter will go more in depth on some more advanced topics, like:

* Strings
* Regexp 
* Date & Time 
* Hashing and Cryptography
* Unit Testing

Everything with more and more useful code snippets.

h3. The Appendices

Last but not least, a HUGE collection of links and resources to learn more about Ruby, and a quick digression on C/C++ extensions... not much, but enough to wet your appetite.


h3. The bottom line

HLRB is not _the only_ book you need to read about Ruby. It's better to make this clear otherwise I'll be hunted forever by Dave Thomas, Chad Fowler, DHH and all the other excellent Ruby hackers who also wrote very successful books (which I bought as well). HLRB is LITTLE and HUMBLE, after all: it doesn't aim at becoming the official Ruby Bible anytime soon (although a bird told me it may get updated _someday_ and include more stuff), but it is still a worthwhile reading.

And of course I came to the very end of this review without mentioning the most important thing: this little wonder is free. All you need is to register to InfoQ (for free) and grab your "free copy":http://www.infoq.com/minibooks/ruby/. If you want you can buy a printed copy for just $9.95, if you feel in a good mood (please do).

The most obvious strengths of this book are the abundance of code examples and very useful working snippets, and the unconventional style which makes it very readable and not boring at all. If I were to name some of its weaknesses (but only if you force me to), I'd say some parts should be expanded and more info on other libraries should be provided... but you never know what the future will bring us!

Well done, "Mr. Neighborly":http://www.jeremymcanally.com/!