all repos — h3rald @ b3442cd80d633f1412303de98a8301e8b8fd86c0

The sources of https://h3rald.com

contents/articles/hlrb-review.html

 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
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
-----
title: "Book Review: Humble Little Ruby Book"
content-type: article
timestamp: 1191383580
tags: "ruby|review|books"
-----
<p>After reading the very first paragraph of Mr. Neighborly's <a href="http://www.humblelittlerubybook.com/">Humble
		Little Ruby Book</a> (<span class="caps">HLRB</span> for
	short, from now on) it was very clear to me that it was going to be quite an unconventional read:</p>
<blockquote>
	<p>&#8220;Yes, there is a Chapter 0. There is a little bit of introductory stuff we need to talk about before <br />
		we set you loose on Ruby. You wouldn't want to get psyched about a new gadget, get it home, <br />
		and then figure out you need batteries, a grapefruit, and the ability to speak three languages to <br />
		even open the box would you?&#8221;</p>
</blockquote>
<p>That reminded me immediately of <a href="http://poignantguide.net/ruby/">Why's Poignant Guide to Ruby</a>.
	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 <span class="caps">HLRB</span>, just some very well made (although still pretty unconventional) diagrams
	like this one:</p>
<p><img src="/images/hlrb_diagram.png" alt="" /></p>
<p>Got the picture? Good. Let's move on&#8230;h3. Chapter 0: What'chu talkin' 'bout, mister?</p>
<p>Chapter 0 is like an introduction to the book <em>and</em> a place to put all the boring stuff you have to talk about
	in a book about a programming language:</p>
<ul>
	<li>What is Ruby?</li>
	<li>Installation procedure (on Windows, Mac OS X and Linux)</li>
	<li>Hello, World!</li>
</ul>
<p>Yes, you can skip this one safely without losing too much, unless of course you still need to install Ruby on your
	machine.</p>
<h3>Chapter 1: Welcome to Ruby.</h3>
<blockquote>
	<p>&#8220;This section aims to introduce the syntactic sugar and linguistic misfortunes of Ruby in the <br />
		quickest manner that will still allow for a full education on the subject.&#8221;</p>
</blockquote>
<p>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). <br />
	Sure, yes, right, whatever&#8230; <em>if you really want</em> 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.</p>
<h3>Chapter 2: Break it down now!</h3>
<p>Or &#8220;learn how to segment your code&#8221; using methods, and&#8230; blocks &amp; <code>Proc</code> 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.</p>
<p><strong>Purist Warning:</strong> 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
	<em>&#8220;Think of Proc objects as blocks that are pushed into variables.&#8221;</em> than anything else,
	guaranteed.
</p>
<p>After this section you'll finally be introduced to Ruby classes. Now, this can piss someone off, no doubt. Ruby
	is a <em>fully OO language</em>, so people <em>must</em> 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. <br />
	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.</p>
<h3>Chapter 3: Hustle and flow (control)</h3>
<p>Finally, the author will deal with flow control. So things like <code>if</code>, <code>case</code>, 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.<br />
	Towards the end of the chapter, you'll also learn how exceptions work: a clever way to tell people &#8220;you
	have to learn how to use exceptions from the very beginning&#8221;. Really nicely done.</p>
<h3>Chapter 4: The system beneath&#8230;</h3>
<p>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 <em>real things</em>. The chapter is full of complete and
	meaningful code snippets which will answer nearly all the questions you may have (at this time):</p>
<ul>
	<li>How do I read and write to a file?</li>
	<li>How do I handle threads and processes?</li>
	<li>How do command-line parameters and environment variables work?</li>
	<li>How can I perform specific Windows-only operations, like reading and writing to the Registry? What about <span
			class="caps">OLE</span> automation?</li>
</ul>
<p>Some of the big books out there will not spend too much time talking about Windows-only libraries, but I found <span
		class="caps">HLRB</span> gives quite a comprehensive introduction about them.</p>
<h3>Chapter 5: Looking beyond home</h3>
<p>More juicy stuff. If you are looking for a tutorial to learn the basics about networking, from from sockets to <span
		class="caps">FTP</span> to <span class="caps">POP</span> 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.<br />
	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 <a href="http://www.pragmaticprogrammer.com/title/rails/">Agile Web Development with Rails</a> for this),
	but will tell you enough to get started.</p>
<h3>Chapter 6: It's a Library!</h3>
<p>The final chapter will go more in depth on some more advanced topics, like:</p>
<ul>
	<li>Strings</li>
	<li>Regexp</li>
	<li>Date &amp; Time</li>
	<li>Hashing and Cryptography</li>
	<li>Unit Testing</li>
</ul>
<p>Everything with more and more useful code snippets.</p>
<h3>The Appendices</h3>
<p>Last but not least, a <span class="caps">HUGE</span> collection of links and resources to learn more about Ruby, and
	a quick digression on C/C++ extensions&#8230; not much, but enough to wet your appetite.</p>
<h3>The bottom line</h3>
<p><span class="caps">HLRB</span> is not <em>the only</em> 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, <span class="caps">DHH</span> and all
	the other excellent Ruby hackers who also wrote very successful books (which I bought as well). <span
		class="caps">HLRB</span> is <span class="caps">LITTLE</span> and <span class="caps">HUMBLE</span>, after all: it
	doesn't aim at becoming the official Ruby Bible anytime soon (although a bird told me it may get updated
	<em>someday</em> and include more stuff), but it is still a worthwhile reading.
</p>
<p>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 <a
		href="http://www.infoq.com/minibooks/ruby/">free copy</a>. If you want you can buy a printed copy for just
	$9.95, if you feel in a good mood (please do).</p>
<p>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&#8230; but you never know what the future will bring us!</p>
<p>Well done, <a href="http://www.jeremymcanally.com/">Mr. Neighborly</a>!</p>