all repos — h3rald @ b3442cd80d633f1412303de98a8301e8b8fd86c0

The sources of https://h3rald.com

contents/articles/distributed-programming-with-ruby-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
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
-----
title: "Book Review: Distributed Programming with Ruby"
content-type: article
subtitle: "Just what you need to get started with the right tools to build large and scalable applications in Ruby"
timestamp: 1277206200
tags: "review|books|ruby"
pdf: true
-----

<section class="section">
	<p>Back when I read <em><a href="http://www.pragprog.com/titles/ruby/programming-ruby">Programming Ruby</a></em> for
		the first time, I distinctly remember a short reference to <a
			href="http://ruby-doc.org/stdlib/libdoc/drb/rdoc/index.html">dRb</a>, the <strong>D</strong>istributed
		<strong>R</strong>u<strong>b</strong>y library included in the Standard Library.
	</p>
	<p><em>&#8220;Cool!&#8221;</em> &#8212; I thought</p>
	<p>&#8230;and that was pretty much it. The documentation for DRb was pretty much nonexistent (at the time), I
		didn't need it, so I pretty much forgot about it altogether until this book came out.</p>
	<p><em><a href="http://www.informit.com/store/product.aspx?isbn=0321638360">Distributed Programming with
				Ruby</a></em> fills a very particular niche of the Ruby programming world: <em>distributed</em>
		programming. Moreover, this book is somehow <em>justified</em> by the scarce documentation on the subject:</p>
	<blockquote>
		<p>Although these libraries [DRb and rinda] have been included with Ruby for many years now, they have received
			little or no attention (or documentation). This has led to a lot of <span class="caps">FUD</span> (fear,
			uncertainty, and doubt) about what these libraries can and cannot do, and when they are appropriate to use
			(if at all).</p>
	</blockquote>
	<p style="padding-left:2rem;">&#8212; Mark Bates, <em><a
				href="http://www.informit.com/store/product.aspx?isbn=0321638360">Distributed Programming with
				Ruby</a></em></p>
	<p>But there's more. This book gives the reader a complete overview of what's out there, in the Ruby
		world, to support distributed programming. This includes quite a few gems and libraries besides the ones
		provided in the standard library.</p>
	<section class="section">
		<header>
			<h1 id="h_1" class="toc">Overview</h1>
		</header>
		<img src="/images/pictures/distributed-programming-with-ruby.jpg" style="float:right;" />
		<p>The book is organized into four parts, each dealing with a particular set of Ruby libraries related to
			distributed programming.</p>
		<p>The author, <a href="http://www.metabates.com/">Mark Bates</a>, does a good job maintaining a sort of
			continuity in the examples throughout the book: you'll get accustomed to a <em>Logger</em> class of
			some kind being punctually re-implemented more or less once per chapter, using a different library.</p>
		<p>Additionally, the libraries described in the book are ordered by &#8220;reverse preference&#8221; in each
			part of the book, so normally the libraries described later on in a part fix some of the shortcomings of the
			preceding ones.</p>



		<section class="section">
			<header>
				<h1 id="h_2" class="toc">Part I: Standard Library</h1>
			</header>
			<p>This part is the most important of all: it gives you the very basics about Distributed Programming and it
				describes the &#8220;building blocks&#8221; (<a
					href="http://ruby-doc.org/stdlib/libdoc/drb/rdoc/index.html">DRb</a> and <a
					href="http://ruby-doc.org/stdlib/libdoc/rinda/rdoc/index.html">Rinda</a>) used in nearly all the
				other libraries described in the book. If you want you can skip some chapters in the other parts of the
				book, but make sure this part is crystal clear in your head before proceeding any further.</p>

		</section>

		<section class="section">
			<header>
				<h1 id="h_3" class="toc">Part II: Third-Party Frameworks and Libraries</h1>
			</header>
			<p>If you read part I, you're probably a bit disappointed by DRb and Rinda and the amount of code you
				have to write to make simple things work in a distributed environment. The good news is that there are
				some Ruby gems out there that can make life simpler:</p>
			<ul>
				<li><a href="http://seattlerb.rubyforge.org/RingyDingy/">RingyDingy</a></li>
				<li><a href="http://rufy.com/starfish/doc/">Starfish</a></li>
				<li><a href="http://github.com/markbates/distribunaut">Distribunaut</a></li>
				<li><a href="http://github.com/mperham/politics">Politics</a></li>
			</ul>

		</section>

		<section class="section">
			<header>
				<h1 id="h_4" class="toc">Part III: Distributed Message Queues</h1>
			</header>
			<p>In this part, the author introduces more in detail the concept of distribute message queues, and also the
				technologies and protocols available not only in the Ruby world but elsewhere. It focuses on two
				libraries:</p>
			<ul>
				<li><a href="http://rubyforge.org/projects/starling/">Starling</a>, originally used by Twitter.</li>
				<li><a href="http://github.com/tmm1/amqp"><span class="caps">AMQP</span></a>, an implementation of the
					<a href="http://www.amqp.org/"><span class="caps">AMQP</span></a> protocol in Ruby, that can be used
					in conjunction with <a href="http://www.rabbitmq.com/">RabbitMQ</a>, an Erlang-based messaging
					system.
				</li>
			</ul>

		</section>

		<section class="section">
			<header>
				<h1 id="h_5" class="toc">Part IV: Distributed Programming with Ruby on Rails</h1>
			</header>
			<p>The book ends somewhat abruptly with this last part that deals with distributed programming in the Rails
				world. It feels a bit like a last-minute addendum that I would have left for an appendix, nevertheless
				it briefly introduces <a href="http://backgroundrb.rubyforge.org/">BackgrounDRb</a> and <a
					href="http://github.com/tobi/delayed_job">Delayed Job</a>.</p>

		</section>

	</section>

	<section class="section">
		<header>
			<h1 id="h_6" class="toc">Technical Analysis</h1>
		</header>
		<p>Unlike other technical books, this one can (must?) be read sequentially. Generally each chapter focuses on a
			library, describes how to install it and use it, and highlights its pros and cons. Typically, the
			&#8220;cons&#8221; are solved in the following chapter by another library, and so on&#8230;</p>
		<p>The book is not meant to contain a full technical reference of each library, and it's quite short (256
			pages), so you really get the most out of it if you read it all, from start to finish. I didn't
			realize there were so many different libraries in this particular niche of Ruby programming, and Mark does a
			good job demistifying some of them.</p>
		<p>One thing that really struck me out of this book is the focus on gems. We're not talking about
			<em>mainstream</em> frameworks like Rails or Merb here, but rather of some rather specialized, smaller
			libraries that fullfill very specific tasks. Personally, I don't remember any other Ruby book doing
			this in the same way, and I was quite happy about it.
		</p>
		<p>On the other hand, gems are a double-edged sword: while some of them are really cool and well-maintained,
			others may disappear tomorrow with no prior notice. I was actually very surprised to see even some of the
			<em>quirks</em> of these gems documented in the book:
		</p>
		<p><strong>p91</strong>: <em>&#8220;Notice that we added client { } to the bottom of the server file. The reason
				for this appears to be a bug or flaw in the Starfish architecture.&#8221;</em></p>
		<p>Really? Hasn't it be fixed now? Apparently not, that's the way it works, so no, you can't
			blame the author of the book for this.</p>

		<section class="section">
			<header>
				<h1 id="h_7" class="toc">Formatting and Readability</h1>
			</header>
			<p>As I pointed out earlier, this book is somehow meant to be read sequentially, and Mark does a good job
				making sure you don't get bored. Chapters and sections are quite short and there's a good
				text/code ratio: the examples are short and clear, and you don't have to try them out yourself,
				because most of the time the author does it for you. It's not infrequent for the author to tell
				you to run &#8220;wrong&#8221; code, but that's a great way to show you how to do the right thing
				right afterwards.</p>
			<p>Sidebars and boxes are used properly and they do provide actual value-added content: some information on
				a non-Ruby technology, some tips and tricks on how to run things smoothly, etc. On the other hand, one
				thing I couldn't stand were the <em>endnotes</em>. I must say I don't like endnotes at the
				best of times, but when they are pointless I just can't suffer them. Each chapter has its own fair
				share of endnotes, but unfortunately most of them are just URLs to Wikipedia pages or RubyForce/GitHub
				projects: I would have preferred the URLs inline with the rest of the text, but that's just me.
			</p>

		</section>
		<section class="section">
			<header>
				<h1 id="h_8" class="toc">Style and Contents</h1>
			</header>
			<p>Mark has a nice, informal writing style. Exactly what you expect from a programming book nowadays, even
				if sometimes it feels a bit too informal:</p>
			<p><strong>p86</strong>: <em>&#8220;I think I understand what Eric means by all that. However, that is as
					deep as the documentation goes on the subject. I have not been able to test what I think he means,
					so I won't make any grand promises about what the library can and cannot do in regards to
					expiring/renewing registrations.&#8221;</em></p>
			<p>Although this is not something you'd see in a professional book everyday, it definitely helps to
				connect with the reader: Mark is one of us after all, even if he happens to have created quite a few <a
					href="http://github.com/markbates">interesting projects</a>, like the Mack framework, the
				Distribunaut library (which is also mentioned in his book, but in a very impartial way) and Configatron.
				From his book you understand that he's neither one of those rockstar developers nor one of those
				famous authors who just writes books for a living: he's a competent programmer who knows quite a
				bit about a particular, but relevant, niche of Ruby programming.</p>

		</section>

	</section>

	<section class="section">
		<header>
			<h1 id="h_9" class="toc">Final Thoughts</h1>
		</header>
		<p>This is one of those books I'd like to see a second edition of. Partly because there are some
			relatively new gems which have been left out (<a href="http://github.com/kwi/BrB">BrB</a>, for example),
			partly because this is a rather hot topic at the moment, and different solutions are popping out at a rather
			extreme rate.</p>
		<p>The decision to write about mainly about gems was bold but necessary, and I'd really like to see more
			authors doing that, but with extra care. From reading this book, you understand that there's no
			<em>silver bullet</em> when it comes to Distributed Programming, but rather different tools to do different
			jobs.
		</p>
		<p>The thing I missed the most? A proper conclusion to the book. You're left with two chapter about
			Rails-specific libraries which could have easily become appendixes, and nothing else. I would have liked a
			sort of &#8220;summing up&#8221; end chapter (re-)highlighting the pros and cons of each library and a sort
			of feature matrix.</p>
		<p>Nevertheless, it was well worth my time and it proved to be a very good resource to get started in writing
			distributed Ruby programs.</p>

	</section>

</section>