<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Merbist &#187; Misc</title>
	<atom:link href="http://merbist.com/category/misc/feed/" rel="self" type="application/rss+xml" />
	<link>http://merbist.com</link>
	<description>Random thoughts of a software developer</description>
	<lastBuildDate>Tue, 03 Jan 2012 02:34:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Books to read in 2012 &#8211; recommended to me by Twitter</title>
		<link>http://merbist.com/2011/12/30/books-to-read-in-2012-recommended-to-me-by-twitter/</link>
		<comments>http://merbist.com/2011/12/30/books-to-read-in-2012-recommended-to-me-by-twitter/#comments</comments>
		<pubDate>Fri, 30 Dec 2011 23:28:13 +0000</pubDate>
		<dc:creator>Matt Aimonetti</dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://merbist.com/?p=1215</guid>
		<description><![CDATA[Today, I asked on Twitter what non-technical books I should read in 2012. I was nicely surprised to see so many of my followers send recommendations. Here is a list of 25 books that like-minded people suggested I read. Hopefully you will find a book or two to read too. Feel free to send more recommendations [...]]]></description>
			<content:encoded><![CDATA[<p>Today, I asked on Twitter what non-technical books I should read in 2012.</p>
<p>I was nicely surprised to see so many of my followers send recommendations. Here is a list of 25 books that like-minded people suggested I read. Hopefully you will find a book or two to read too. Feel free to send more recommendations via the comments.</p>
<p>&nbsp;</p>
<table>
<tbody>
<tr>
<td><a href="http://www.amazon.com/gp/product/0307593312/ref=as_li_ss_il?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0307593312"><img src="http://ws.assoc-amazon.com/widgets/q?_encoding=UTF8&amp;Format=_SL110_&amp;ASIN=0307593312&amp;MarketPlace=US&amp;ID=AsinImage&amp;WS=1&amp;tag=merbist-20&amp;ServiceVersion=20070822" alt="" border="0" /></a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=0307593312" alt="" width="1" height="1" border="0" /></td>
<td><a href="http://www.amazon.com/gp/product/0307593312/ref=as_li_ss_tl?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0307593312" target="_blank">1Q84 by Haruki Murakami</a></td>
<td>suggested by <a title="@mrb_bk" href="https://twitter.com/#!/mrb_bk" target="_blank">@mrb_bk</a> and <a href="https://twitter.com/#!/chadfowler" target="_blank">@chadfowler</a></td>
</tr>
<tr>
<td><a href="http://www.amazon.com/gp/product/0385240899/ref=as_li_ss_il?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0385240899"><img src="http://ws.assoc-amazon.com/widgets/q?_encoding=UTF8&amp;Format=_SL110_&amp;ASIN=0385240899&amp;MarketPlace=US&amp;ID=AsinImage&amp;WS=1&amp;tag=merbist-20&amp;ServiceVersion=20070822" alt="" border="0" /></a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=0385240899" alt="" width="1" height="1" border="0" /></td>
<td><a href="http://www.amazon.com/gp/product/0385240899/ref=as_li_ss_tl?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0385240899">The Floating Opera and The End of the Road by John Barth</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=0385240899" alt="" width="1" height="1" border="0" /></td>
<td>suggested by <a title="@chadfowler" href="https://twitter.com/#!/chadfowler" target="_blank">@chadfowler</a></td>
</tr>
<tr>
<td><a href="http://www.amazon.com/gp/product/0613663616/ref=as_li_ss_il?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0613663616"><img src="http://ws.assoc-amazon.com/widgets/q?_encoding=UTF8&amp;Format=_SL110_&amp;ASIN=0613663616&amp;MarketPlace=US&amp;ID=AsinImage&amp;WS=1&amp;tag=merbist-20&amp;ServiceVersion=20070822" alt="" border="0" /></a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=0613663616" alt="" width="1" height="1" border="0" /></td>
<td><a href="http://www.amazon.com/gp/product/0613663616/ref=as_li_ss_tl?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0613663616">Into Thin Air by Jon Krakauer</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=0613663616" alt="" width="1" height="1" border="0" /></td>
<td>suggested by <a title="@bradly" href="https://twitter.com/#!/bradly" target="_blank">@bradly</a></td>
</tr>
<tr>
<td><a href="http://www.amazon.com/gp/product/0375714367/ref=as_li_ss_il?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0375714367"><img src="http://ws.assoc-amazon.com/widgets/q?_encoding=UTF8&amp;Format=_SL110_&amp;ASIN=0375714367&amp;MarketPlace=US&amp;ID=AsinImage&amp;WS=1&amp;tag=merbist-20&amp;ServiceVersion=20070822" alt="" border="0" /></a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=0375714367" alt="" width="1" height="1" border="0" /></td>
<td><a href="http://www.amazon.com/gp/product/0375714367/ref=as_li_ss_tl?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0375714367">Cutting for Stone by Abraham Verghese</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=0375714367" alt="" width="1" height="1" border="0" /></td>
<td>suggested by <a title="@bradly" href="https://twitter.com/#!/bradly" target="_blank">@bradly</a></td>
</tr>
<tr>
<td><a href="http://www.amazon.com/gp/product/0452011876/ref=as_li_ss_il?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0452011876"><img src="http://ws.assoc-amazon.com/widgets/q?_encoding=UTF8&amp;Format=_SL110_&amp;ASIN=0452011876&amp;MarketPlace=US&amp;ID=AsinImage&amp;WS=1&amp;tag=merbist-20&amp;ServiceVersion=20070822" alt="" border="0" /></a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=0452011876" alt="" width="1" height="1" border="0" /></td>
<td><a href="http://www.amazon.com/gp/product/0452011876/ref=as_li_ss_tl?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0452011876">Atlas Shrugged by Ayn Rand</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=0452011876" alt="" width="1" height="1" border="0" /></td>
<td>suggested by <a title="@bradly" href="https://twitter.com/#!/bradly" target="_blank">@bradly</a></td>
</tr>
<tr>
<td><a href="http://www.amazon.com/gp/product/0307474720/ref=as_li_ss_il?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0307474720"><img src="http://ws.assoc-amazon.com/widgets/q?_encoding=UTF8&amp;Format=_SL110_&amp;ASIN=0307474720&amp;MarketPlace=US&amp;ID=AsinImage&amp;WS=1&amp;tag=merbist-20&amp;ServiceVersion=20070822" alt="" border="0" /></a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=0307474720" alt="" width="1" height="1" border="0" /></td>
<td><a href="http://www.amazon.com/gp/product/0307474720/ref=as_li_ss_tl?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0307474720">Cien años de soledad by Gabriel Garcia Marquez</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=0307474720" alt="" width="1" height="1" border="0" /> (es)</td>
<td>suggested by <a title="@romanandreg" href="https://twitter.com/#!/romanandreg" target="_blank">@romanandreg</a> &amp; <a href="https://twitter.com/#!/jrfernandez" target="_blank">@jrfernandez</a> &amp; <a href="https://twitter.com/#!/edgarschmidt" data-user-id="15151306">@edgarschmidt</a></td>
</tr>
<tr>
<td><a href="http://www.amazon.com/gp/product/0060883286/ref=as_li_ss_il?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0060883286"><img src="http://ws.assoc-amazon.com/widgets/q?_encoding=UTF8&amp;Format=_SL110_&amp;ASIN=0060883286&amp;MarketPlace=US&amp;ID=AsinImage&amp;WS=1&amp;tag=merbist-20&amp;ServiceVersion=20070822" alt="" border="0" /></a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=0060883286" alt="" width="1" height="1" border="0" /></td>
<td><a href="http://www.amazon.com/gp/product/0060883286/ref=as_li_ss_tl?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0060883286">One Hundred Years of Solitude by Gabriel García Marquez</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=0060883286" alt="" width="1" height="1" border="0" /></td>
<td>suggested by <a title="@romanandreg" href="https://twitter.com/#!/romanandreg" target="_blank">@romanandreg</a> &amp; <a href="https://twitter.com/#!/jrfernandez" target="_blank">@jrfernandez</a> &amp; <a href="https://twitter.com/#!/edgarschmidt" data-user-id="15151306">@edgarschmidt</a></td>
</tr>
<tr>
<td><a href="http://www.amazon.com/gp/product/0553348981/ref=as_li_ss_il?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0553348981"><img src="http://ws.assoc-amazon.com/widgets/q?_encoding=UTF8&amp;Format=_SL110_&amp;ASIN=0553348981&amp;MarketPlace=US&amp;ID=AsinImage&amp;WS=1&amp;tag=merbist-20&amp;ServiceVersion=20070822" alt="" border="0" /></a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=0553348981" alt="" width="1" height="1" border="0" /></td>
<td><a href="http://www.amazon.com/gp/product/0553348981/ref=as_li_ss_tl?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0553348981">Jitterbug Perfume by Tom Robbins</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=0553348981" alt="" width="1" height="1" border="0" /></td>
<td>suggested by <a title="@supaspoida" href="https://twitter.com/#!/supaspoida" target="_blank">@supaspoida</a></td>
</tr>
<tr>
<td><a href="http://www.amazon.com/gp/product/0062041266/ref=as_li_ss_il?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0062041266"><img src="http://ws.assoc-amazon.com/widgets/q?_encoding=UTF8&amp;Format=_SL110_&amp;ASIN=0062041266&amp;MarketPlace=US&amp;ID=AsinImage&amp;WS=1&amp;tag=merbist-20&amp;ServiceVersion=20070822" alt="" border="0" /></a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=0062041266" alt="" width="1" height="1" border="0" /></td>
<td><a href="http://www.amazon.com/gp/product/0062041266/ref=as_li_ss_tl?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0062041266">The Sisters Brothers by Patrick deWitt</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=0062041266" alt="" width="1" height="1" border="0" /></td>
<td>suggested by <a title="@dennismajor1" href="https://twitter.com/#!/dennismajor1" target="_blank">@dennismajor1</a></td>
</tr>
<tr>
<td><a href="http://www.amazon.com/gp/product/0312278497/ref=as_li_ss_il?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0312278497"><img src="http://ws.assoc-amazon.com/widgets/q?_encoding=UTF8&amp;Format=_SL110_&amp;ASIN=0312278497&amp;MarketPlace=US&amp;ID=AsinImage&amp;WS=1&amp;tag=merbist-20&amp;ServiceVersion=20070822" alt="" border="0" /></a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=0312278497" alt="" width="1" height="1" border="0" /></td>
<td><a href="http://www.amazon.com/gp/product/0312278497/ref=as_li_ss_tl?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0312278497">The Glass Bead Game by Hermann Hesse</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=0312278497" alt="" width="1" height="1" border="0" /></td>
<td>suggested by <a title="@dj2sincl" href="https://twitter.com/#!/dj2sincl" target="_blank">@dj2sincl</a></td>
</tr>
<tr>
<td><a href="http://www.amazon.com/gp/product/0679775439/ref=as_li_ss_il?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0679775439"><img src="http://ws.assoc-amazon.com/widgets/q?_encoding=UTF8&amp;Format=_SL110_&amp;ASIN=0679775439&amp;MarketPlace=US&amp;ID=AsinImage&amp;WS=1&amp;tag=merbist-20&amp;ServiceVersion=20070822" alt="" border="0" /></a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=0679775439" alt="" width="1" height="1" border="0" /></td>
<td><a href="http://www.amazon.com/gp/product/0679775439/ref=as_li_ss_tl?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0679775439">The Wind-Up Bird Chronicle by Haruki Murakami</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=0679775439" alt="" width="1" height="1" border="0" /></td>
<td>suggested by <a title="@chadfowler" href="https://twitter.com/#!/chadfowler" target="_blank">@chadfowler</a></td>
</tr>
<tr>
<td><a href="http://www.amazon.com/gp/product/0983873100/ref=as_li_ss_il?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0983873100"><img src="http://ws.assoc-amazon.com/widgets/q?_encoding=UTF8&amp;Format=_SL110_&amp;ASIN=0983873100&amp;MarketPlace=US&amp;ID=AsinImage&amp;WS=1&amp;tag=merbist-20&amp;ServiceVersion=20070822" alt="" border="0" /></a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=0983873100" alt="" width="1" height="1" border="0" /></td>
<td><a href="http://www.amazon.com/gp/product/0983873100/ref=as_li_ss_tl?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0983873100">Mindfire by Scott Berkun</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=0983873100" alt="" width="1" height="1" border="0" /></td>
<td>suggested by <a title="@lucasdicioccio" href="https://twitter.com/#!/lucasdicioccio" target="_blank">@lucasdicioccio</a></td>
</tr>
<tr>
<td><a href="http://www.amazon.com/gp/product/2226052577/ref=as_li_ss_il?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=2226052577"><img src="http://ws.assoc-amazon.com/widgets/q?_encoding=UTF8&amp;Format=_SL110_&amp;ASIN=2226052577&amp;MarketPlace=US&amp;ID=AsinImage&amp;WS=1&amp;tag=merbist-20&amp;ServiceVersion=20070822" alt="" border="0" /></a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=2226052577" alt="" width="1" height="1" border="0" /></td>
<td><a href="http://www.amazon.com/gp/product/2226052577/ref=as_li_ss_tl?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=2226052577">Les Fourmis by Bernard Werber</a> (fr)</td>
<td>suggested by <a title="@twitty_tim" href="https://twitter.com/#!/twitty_tim" target="_blank">@twitty_tim</a></td>
</tr>
<tr>
<td><a href="http://www.amazon.com/gp/product/0375725849/ref=as_li_ss_il?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0375725849"><img src="http://ws.assoc-amazon.com/widgets/q?_encoding=UTF8&amp;Format=_SL110_&amp;ASIN=0375725849&amp;MarketPlace=US&amp;ID=AsinImage&amp;WS=1&amp;tag=merbist-20&amp;ServiceVersion=20070822" alt="" border="0" /></a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=0375725849" alt="" width="1" height="1" border="0" /></td>
<td><a href="http://www.amazon.com/gp/product/0375725849/ref=as_li_ss_tl?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0375725849">Perfume: The Story of a Murderer by Patrick Suskind</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=0375725849" alt="" width="1" height="1" border="0" /></td>
<td>suggested by <a title="@twitty_tim" href="https://twitter.com/#!/twitty_tim" target="_blank">@twitty_tim</a></td>
</tr>
<tr>
<td><a href="http://www.amazon.com/gp/product/1613820259/ref=as_li_ss_il?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1613820259"><img src="http://ws.assoc-amazon.com/widgets/q?_encoding=UTF8&amp;Format=_SL110_&amp;ASIN=1613820259&amp;MarketPlace=US&amp;ID=AsinImage&amp;WS=1&amp;tag=merbist-20&amp;ServiceVersion=20070822" alt="" border="0" /></a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=1613820259" alt="" width="1" height="1" border="0" /></td>
<td><a href="http://www.amazon.com/gp/product/1613820259/ref=as_li_ss_tl?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1613820259">Les Miserables by Victor Hugo</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=1613820259" alt="" width="1" height="1" border="0" /> (en, free ebook)</td>
<td>suggested by <a title="@tutec" href="https://twitter.com/#!/tutec" target="_blank">@tutec</a></td>
</tr>
<tr>
<td><a href="http://www.amazon.com/gp/product/0307292134/ref=as_li_ss_il?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0307292134"><img src="http://ws.assoc-amazon.com/widgets/q?_encoding=UTF8&amp;Format=_SL110_&amp;ASIN=0307292134&amp;MarketPlace=US&amp;ID=AsinImage&amp;WS=1&amp;tag=merbist-20&amp;ServiceVersion=20070822" alt="" border="0" /></a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=0307292134" alt="" width="1" height="1" border="0" /></td>
<td><a href="http://www.amazon.com/gp/product/0307292134/ref=as_li_ss_tl?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0307292134">Song Of Ice and Fire by George R.R. Martin</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=0307292134" alt="" width="1" height="1" border="0" /> (Game of Thrones saga)</td>
<td>suggested by <a title="@eeppa" href="https://twitter.com/#!/eeppa" target="_blank">@eeppa</a> &amp; <a href="http://twitter.com/jarin" target="_blank">@jarin</a></td>
</tr>
<tr>
<td><a href="http://www.amazon.com/gp/product/0765329468/ref=as_li_ss_il?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0765329468"><img src="http://ws.assoc-amazon.com/widgets/q?_encoding=UTF8&amp;Format=_SL110_&amp;ASIN=0765329468&amp;MarketPlace=US&amp;ID=AsinImage&amp;WS=1&amp;tag=merbist-20&amp;ServiceVersion=20070822" alt="" border="0" /></a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=0765329468" alt="" width="1" height="1" border="0" /></td>
<td><a href="http://www.amazon.com/gp/product/0765329468/ref=as_li_ss_tl?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0765329468">Clockwork Century by Cherie Priest</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=0765329468" alt="" width="1" height="1" border="0" /></td>
<td>suggested by <a title="@eeppa" href="https://twitter.com/#!/eeppa" target="_blank">@eeppa</a></td>
</tr>
<tr>
<td><a href="http://www.amazon.com/gp/product/1590201183/ref=as_li_ss_il?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1590201183"><img src="http://ws.assoc-amazon.com/widgets/q?_encoding=UTF8&amp;Format=_SL110_&amp;ASIN=1590201183&amp;MarketPlace=US&amp;ID=AsinImage&amp;WS=1&amp;tag=merbist-20&amp;ServiceVersion=20070822" alt="" border="0" /></a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=1590201183" alt="" width="1" height="1" border="0" /></td>
<td><a href="http://www.amazon.com/gp/product/1590201183/ref=as_li_ss_tl?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1590201183">The Darkness that Comes Before by R. Scott Bakker</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=1590201183" alt="" width="1" height="1" border="0" /></td>
<td>suggested by <a title="@eeppa" href="https://twitter.com/#!/eeppa" target="_blank">@eeppa</a></td>
</tr>
<tr>
<td><a href="http://www.amazon.com/gp/product/B003GAN3VE/ref=as_li_ss_il?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=B003GAN3VE"><img src="http://ws.assoc-amazon.com/widgets/q?_encoding=UTF8&amp;Format=_SL110_&amp;ASIN=B003GAN3VE&amp;MarketPlace=US&amp;ID=AsinImage&amp;WS=1&amp;tag=merbist-20&amp;ServiceVersion=20070822" alt="" border="0" /></a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=B003GAN3VE" alt="" width="1" height="1" border="0" /></td>
<td><a href="http://www.amazon.com/gp/product/B003GAN3VE/ref=as_li_ss_tl?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=B003GAN3VE">Drood by Dan Simmons</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=B003GAN3VE" alt="" width="1" height="1" border="0" /></td>
<td>suggested by <a title="@eeppa" href="https://twitter.com/#!/eeppa" target="_blank">@eeppa</a></td>
</tr>
<tr>
<td><a href="http://www.amazon.com/gp/product/0316068225/ref=as_li_ss_il?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0316068225"><img src="http://ws.assoc-amazon.com/widgets/q?_encoding=UTF8&amp;Format=_SL110_&amp;ASIN=0316068225&amp;MarketPlace=US&amp;ID=AsinImage&amp;WS=1&amp;tag=merbist-20&amp;ServiceVersion=20070822" alt="" border="0" /></a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=0316068225" alt="" width="1" height="1" border="0" /></td>
<td><a href="http://www.amazon.com/gp/product/0316068225/ref=as_li_ss_tl?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0316068225">This Is Water by David Foster Wallace</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=0316068225" alt="" width="1" height="1" border="0" /></td>
<td>suggested by <a title="@atduskgreg" href="https://twitter.com/#!/atduskgreg" target="_blank">@atduskgreg</a></td>
</tr>
<tr>
<td><a href="http://www.amazon.com/gp/product/B005DI71QA/ref=as_li_ss_il?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=B005DI71QA"><img src="http://ws.assoc-amazon.com/widgets/q?_encoding=UTF8&amp;Format=_SL110_&amp;ASIN=B005DI71QA&amp;MarketPlace=US&amp;ID=AsinImage&amp;WS=1&amp;tag=merbist-20&amp;ServiceVersion=20070822" alt="" border="0" /></a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=B005DI71QA" alt="" width="1" height="1" border="0" /></td>
<td><a href="http://www.amazon.com/gp/product/B005DI71QA/ref=as_li_ss_tl?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=B005DI71QA">Anathem by Neal Stephenson</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=B005DI71QA" alt="" width="1" height="1" border="0" /></td>
<td>suggested by <a title="@jarin" href="https://twitter.com/#!/jarin" target="_blank">@jarin</a></td>
</tr>
<tr>
<td><a href="http://www.amazon.com/gp/product/0812550706/ref=as_li_ss_il?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0812550706"><img src="http://ws.assoc-amazon.com/widgets/q?_encoding=UTF8&amp;Format=_SL110_&amp;ASIN=0812550706&amp;MarketPlace=US&amp;ID=AsinImage&amp;WS=1&amp;tag=merbist-20&amp;ServiceVersion=20070822" alt="" border="0" /></a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=0812550706" alt="" width="1" height="1" border="0" /></td>
<td><a href="http://www.amazon.com/gp/product/0812550706/ref=as_li_ss_tl?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0812550706">Ender&#8217;s Game by Orson Scott Card</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=0812550706" alt="" width="1" height="1" border="0" /> (entire saga)</td>
<td>suggested by <a title="@jarin" href="https://twitter.com/#!/jarin" target="_blank">@jarin</a> &amp; <a href="https://twitter.com/#!/edgarschmidt" target="_blank" data-user-id="15151306">@edgarschmidt</a></td>
</tr>
<tr>
<td><a href="http://www.amazon.com/gp/product/344245302X/ref=as_li_ss_il?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=344245302X"><img src="http://ws.assoc-amazon.com/widgets/q?_encoding=UTF8&amp;Format=_SL110_&amp;ASIN=344245302X&amp;MarketPlace=US&amp;ID=AsinImage&amp;WS=1&amp;tag=merbist-20&amp;ServiceVersion=20070822" alt="" border="0" /></a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=344245302X" alt="" width="1" height="1" border="0" /></td>
<td><a href="http://www.amazon.com/gp/product/344245302X/ref=as_li_ss_tl?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=344245302X">Snow Crash by Neal Stephenson</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=344245302X" alt="" width="1" height="1" border="0" /></td>
<td>suggested by <a title="@jarin" href="https://twitter.com/#!/jarin" target="_blank">@jarin</a></td>
</tr>
<tr>
<td><a href="http://www.amazon.com/gp/product/1422171647/ref=as_li_ss_il?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1422171647"><img src="http://ws.assoc-amazon.com/widgets/q?_encoding=UTF8&amp;Format=_SL110_&amp;ASIN=1422171647&amp;MarketPlace=US&amp;ID=AsinImage&amp;WS=1&amp;tag=merbist-20&amp;ServiceVersion=20070822" alt="" border="0" /></a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=1422171647" alt="" width="1" height="1" border="0" /></td>
<td><a href="http://www.amazon.com/gp/product/1422171647/ref=as_li_ss_tl?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1422171647">Fixing the Game by Roger L. Martin</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=1422171647" alt="" width="1" height="1" border="0" /></td>
<td>suggested by <a title="@jarkko" href="https://twitter.com/#!/jarkko" target="_blank">@jarkko</a></td>
</tr>
<tr>
<td><a href="http://www.amazon.com/gp/product/0307387895/ref=as_li_ss_il?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0307387895"><img src="http://ws.assoc-amazon.com/widgets/q?_encoding=UTF8&amp;Format=_SL110_&amp;ASIN=0307387895&amp;MarketPlace=US&amp;ID=AsinImage&amp;WS=1&amp;tag=merbist-20&amp;ServiceVersion=20070822" alt="" border="0" /></a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=0307387895" alt="" width="1" height="1" border="0" /></td>
<td><a href="http://www.amazon.com/gp/product/0307387895/ref=as_li_ss_tl?ie=UTF8&amp;tag=merbist-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0307387895">The Road by Cormac McCarthy</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=merbist-20&amp;l=as2&amp;o=1&amp;a=0307387895" alt="" width="1" height="1" border="0" /></td>
<td>suggested by <a title="@mrreynolds" href="https://twitter.com/#!/mrreynolds" target="_blank">@mrreynolds</a></td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://merbist.com/2011/12/30/books-to-read-in-2012-recommended-to-me-by-twitter/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Developing a Curriculum</title>
		<link>http://merbist.com/2011/12/21/developing-a-curriculum/</link>
		<comments>http://merbist.com/2011/12/21/developing-a-curriculum/#comments</comments>
		<pubDate>Wed, 21 Dec 2011 14:57:27 +0000</pubDate>
		<dc:creator>Matt Aimonetti</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[education]]></category>

		<guid isPermaLink="false">http://merbist.com/?p=1207</guid>
		<description><![CDATA[Recently I asked a friend of mine to give me pointers on how to develop a curriculum (he used to teach an education PHD program), after discussing his response on Twitter, people asked me to put it somewhere, so here it is: Process to develop a curriculum: Purpose. Know why you&#8217;re doing what you&#8217;re doing. [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I asked a friend of mine to give me pointers on how to develop a curriculum (he used to teach an education PHD program), after discussing his response on Twitter, people asked me to put it somewhere, so here it is:</p>
<p>Process to develop a curriculum:</p>
<p><span style="text-decoration: underline;"><strong>Purpose</strong></span>. <em>Know why you&#8217;re doing what you&#8217;re doing.</em></p>
<ul>
<li>You know how to do this.</li>
</ul>
<p><span style="text-decoration: underline;"><strong>Product</strong></span>. <em>Start with the end in mind.</em></p>
<ul>
<li>What does the student look like when they walk out the door at the end of the training.</li>
<li>Usually, we break these down into <strong>Knowledge</strong>, <strong>Skills</strong>, or <strong>Attitudes</strong>.</li>
<li>Sometimes it&#8217;s helpful to see a photograph or drawing of a someone who finished the program and just talk about what they can do that makes them successful.</li>
<li>This &#8220;product&#8221; should be connected and help you accomplish your mission</li>
</ul>
<p><span style="text-decoration: underline;"><strong>Practices</strong></span>. <em>Then ask yourself, &#8220;How do people become like this?&#8221;</em></p>
<ul>
<li>If you can break down your Product into 3-5 bit-sized chunks, then see how people learn each one of those skills, gain each one of those knowledge points, and how to they gain the attitudes you want them to have.</li>
<li>This one is much easier the more experience you have in seeing people develop the &#8220;Product.&#8221;</li>
<li>This is also easier to determine when you understand <a href="http://en.wikipedia.org/wiki/Learning_theory_(education)" target="_blank">Learning Theory</a>.</li>
<li>The results from this section will result in a list of:</li>
<ul>
<li>       Activities or experiences</li>
<li>       Resources. What books, website, teachers, software, etc. will help them learn more effectively and efficiently</li>
<li>       Assessments. How you would know if the activity was helpful?</li>
</ul>
</ul>
<p><span style="text-decoration: underline;"><strong>Plans</strong></span>. <em>Make your plans based on the practices you&#8217;ve determined you&#8217;ve needed.</em></p>
<p>&nbsp;</p>
<p>On a related topic, Chad Fowler posted an interesting <a href="http://chadfowler.com/2011/12/21/re-thinking-software-development-education" target="_blank">blog post about what LivingSocial is doing to change the software development education</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://merbist.com/2011/12/21/developing-a-curriculum/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Data safety and GIL removal</title>
		<link>http://merbist.com/2011/10/18/data-safety-and-gil-removal/</link>
		<comments>http://merbist.com/2011/10/18/data-safety-and-gil-removal/#comments</comments>
		<pubDate>Tue, 18 Oct 2011 23:19:17 +0000</pubDate>
		<dc:creator>Matt Aimonetti</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[concurrency]]></category>
		<category><![CDATA[gil]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://merbist.com/?p=1188</guid>
		<description><![CDATA[After my recent RubyConf talk and follow up post addressing the Ruby &#38; Python&#8217;s Global Interpreter Lock (aka GVL/Global VM Lock). a lot of people asked me to explain what I meant by &#8220;data safety&#8221;. While my point isn&#8217;t to defend one approach or the other, I spent a lot of time explaining why C [...]]]></description>
			<content:encoded><![CDATA[<p>After my recent <a title="RubyConf 2011 slides" href="http://rubyconf11.merbist.com" target="_blank">RubyConf talk</a> and <a title="About concurrency and the GIL" href="http://merbist.com/2011/10/03/about-concurrency-and-the-gil/" target="_blank">follow up post addressing the Ruby &amp; Python&#8217;s Global Interpreter Lock</a> (aka GVL/Global VM Lock). a lot of people asked me to explain what I meant by &#8220;data safety&#8221;. While my point isn&#8217;t to defend one approach or the other, I spent a lot of time explaining why C Ruby and C Python use a GIL and where it matters and where it matters less. As a reminder and as mentioned by Matz himself, the main reason why C Ruby still has a GIL is data safety. But if this point isn&#8217;t clear to you, you might be missing the main argument supporting the use of a GIL.</p>
<p>Showing obvious concrete examples of data corruption due to unsafe threaded code isn&#8217;t actually as easy at it sounds. First of all, even with a GIL, developers can write unsafe threaded code. So we need to focus only on the safety problems raised by removing the GIL. To demonstrate what I mean, I will try to create some race conditions and show you the unexpected results you might get. Again, before you go crazy on the comments, remember that threaded code is indeterministic and the code below might potentially work on your machine and that&#8217;s exactly why it is hard to demonstrate. Race conditions depend on many things, but in this case I will focus on race conditions affecting basic data structures since it might be the most surprising.</p>
<h2>Example:</h2>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">@<span style="color:#CC0066; font-weight:bold;">array</span>, threads = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span>, <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
<span style="color:#006666;">4</span>.<span style="color:#9900CC;">times</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  threads <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#CC00FF; font-weight:bold;">Thread</span>.<span style="color:#9900CC;">new</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">1</span>..<span style="color:#006666;">100</span>_000<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">each</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>n<span style="color:#006600; font-weight:bold;">|</span> @<span style="color:#CC0066; font-weight:bold;">array</span> <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> n<span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
threads.<span style="color:#9900CC;">each</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>t<span style="color:#006600; font-weight:bold;">|</span> t.<span style="color:#9900CC;">join</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#CC0066; font-weight:bold;">puts</span> @<span style="color:#CC0066; font-weight:bold;">array</span>.<span style="color:#9900CC;">size</span></pre></div></div>

<p>In the above example, I&#8217;m creating an instance variable of Array type and I start 4 threads. Each of these threads adds 100,000 items to the array. We then wait for all the threads to be done and check the size of the array.</p>
<p>If you run this code in C Ruby the end result will be as expected:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#006666;">400000</span></pre></div></div>

<p>Now if you switch to JRuby you might be surprised by the output. If you are lucky you will see the following:</p>
<pre>ConcurrencyError: Detected invalid array contents due to unsynchronized modifications with concurrent users
        &lt;&lt; at org/jruby/RubyArray.java:1147
  __file__ at demo.rb:3
      each at org/jruby/RubyRange.java:407
  __file__ at demo.rb:3
      call at org/jruby/RubyProc.java:274
      call at org/jruby/RubyProc.java:233</pre>
<p>This is actually a good thing. JRuby detects that you are unsafely modifying an instance variable across threads and that data corruption will occur. However, the exception doesn&#8217;t always get raised and you will potentially see results such as:</p>
<pre>335467
342397
341080</pre>
<p>This is a sign that the data was corrupted but that JRuby didn&#8217;t catch the unsynchronized modification. On the other hand MacRuby and Rubinius 2 (dev) won&#8217;t raise any exceptions and will just corrupt the data, outputting something like:</p>
<pre>294278
285755
280704
279865</pre>
<p>In other words, if not manually synchronized, shared data can easily be corrupted. You might have two threads modifying the value of the same variable and one of the two threads will step on top of the other leaving you with a race condition. You only need 2 threads accessing the same instance variable at the same time to get a race condition. My example uses more threads and more mutations to make the problem more obvious. Note that TDD wouldn&#8217;t catch such an issue and even extensive testing will provide very little guarantee that your code is thread safe.</p>
<p>&nbsp;</p>
<h2>So what? Thread safety isn&#8217;t a new problem.</h2>
<p>That&#8217;s absolutely correct, ask any decent Java developer out there, he/she will tell how locks are used to &#8220;easily&#8221; synchronize objects to make your code thread safe. They might also mention the deadlocks and other issues related to that, but that&#8217;s a different story. One might also argue that when you write web apps, there is very little shared data and the chances of corrupting data across concurrent requests is very small since most of the data is kept in a shared data store outside of the process.</p>
<p>All these arguments are absolutely valid, the challenge is that you have a large community and a large amount of code out there that expects a certain behavior. And removing the GIL does change this behavior. It might not be a big deal for you because you know how to deal with thread safety, but it might be a big deal for others and C Ruby is by far the most used Ruby implementation. It&#8217;s basically like saying that automatic cars shouldn&#8217;t be made and sold, and everybody has to switch to stick shifts. They have better gas mileage, I personally enjoy driving then and they are cheaper to build. Removing the GIL is a bit like that. There is a cost associated with this decision and while this cost isn&#8217;t insane, the people in charge prefer to not pay it.</p>
<p>&nbsp;</p>
<h2>Screw that, I&#8217;ll switch to Node.js</h2>
<p>I heard a lot of people telling me they were looking into using Node.js because it has a better design and no GIL. While I like Node.js and if I were to implement a chat room or an app keeping connections for a long time, I would certainly compare it closely to EventMachine, I also think that this argument related to the GIL is absurd. First, you have other Ruby implementations which don&#8217;t have a GIL and are really stable (i.e: JRuby) but then Node basically works the same as Ruby with a GIL. Yes, Node is evented and single threaded but when you think about it, it behaves the same as Ruby 1.9 with its GIL. Many requests come in and they are handled one after the other and because IO requests are non-blocking, multiple requests can be processed concurrently but not in parallel. Well folks, that&#8217;s exactly how C Ruby works too, and unlike popular believe, most if not all the popular libraries making IO requests are non blocking (when using 1.9). So, next time you try to justify you wanting to toy with Node, please don&#8217;t use the GIL argument.</p>
<p>&nbsp;</p>
<h2>What should I do?</h2>
<p>As always, evaluate your needs and see what makes sense for your project. Start by making sure you are using Ruby 1.9 and your code makes good use of threading. Then look at your app and how it behaves, is it CPU-bound or IO-bound. Most web apps out there are IO-bound (waiting for the DB, redis or API calls), and when doing an IO call, Ruby&#8217;s GIL is released allowing another thread to do its work. In that case, not having a GIL in your Ruby implementation won&#8217;t help you. However, if your app is CPU-bound, then switching to JRuby or Rubinius might be beneficial. However, don&#8217;t assume anything until you proved it and remember that making such a change will more than likely require some architectural redesign, especially if using JRuby.  But, hey, it might totally be worth it as many proved it in the past.</p>
<p>&nbsp;</p>
<p>I hope I was able to clarify things a bit further. If you wish to dig further, I would highly recommend you read the many discussions the Python community had in the last few years.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://merbist.com/2011/10/18/data-safety-and-gil-removal/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>About management</title>
		<link>http://merbist.com/2011/10/11/about-management/</link>
		<comments>http://merbist.com/2011/10/11/about-management/#comments</comments>
		<pubDate>Wed, 12 Oct 2011 06:53:40 +0000</pubDate>
		<dc:creator>Matt Aimonetti</dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://merbist.com/?p=1173</guid>
		<description><![CDATA[I decided to save myself a session to the shrink and instead just write down my reflection on management. Who knows, some of you might help me and/or challenge my thought process. I recently read a great management book called the five dysfunctions of a team by Patrick Lencioni . Instead of telling you what [...]]]></description>
			<content:encoded><![CDATA[<p>I decided to save myself a session to the shrink and instead just write down my reflection on management. Who knows, some of you might help me and/or challenge my thought process.</p>
<p>I recently read a great management book called the <a title="5 dysfunctions of a team" href="https://www.amazon.com/dp/B000UCUX0K/ref=as_li_ss_til?tag=merbist-20&amp;camp=213381&amp;creative=390973&amp;linkCode=as4&amp;creativeASIN=B000UCUX0K&amp;adid=0BP6N5GHZD0EW2N7QVZR&amp;" target="_blank">five dysfunctions of a team by Patrick Lencioni</a> . Instead of telling you what to do, the author highlights behavior patterns that are related to each other and when aggregated result in dysfunctional teams. I really liked the book because instead of a being a cookbook/playbook, this is more a fail book, in other words, it illustrates what you don&#8217;t want to do and explains why. It highlights very well the relation between various behaviors and nicely illustrates why teams of brilliant people can fail. The <a href="https://www.amazon.com/dp/B000UCUX0K/ref=as_li_ss_til?tag=merbist-20&amp;camp=213381&amp;creative=390973&amp;linkCode=as4&amp;creativeASIN=B000UCUX0K&amp;adid=0BP6N5GHZD0EW2N7QVZR&amp;" target="_blank">Kindle version is at less than $5, go get it</a> and read it on your iPhone/iPad/computer/browser…</p>
<div style="margin-left: 50%;"><iframe src="http://rcm.amazon.com/e/cm?lt1=_blank&#038;bc1=000000&#038;IS2=1&#038;bg1=FFFFFF&#038;fc1=000000&#038;lc1=0000FF&#038;t=merbist-20&#038;o=1&#038;p=8&#038;l=as4&#038;m=amazon&#038;f=ifr&#038;ref=ss_til&#038;asins=B000UCUX0K" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></div>
<p>So this book somewhat changed my perception of management and leadership. Interesting enough, at Sony, my previous employer, they make a distinction between management and leadership. While they hope managers can be leaders, they don&#8217;t require them to be and to be honest very few are. I&#8217;m not sure that&#8217;s a good or a bad things, but I, for sure, was under different expectations. Finally, I spent a large amount of my life on the internet working on/with projects where meritocracy, respect and honor were key. The &#8220;ranking&#8221; is purely based on what your peers think of you and not based on your age/sex/origin/diploma/bank account. I do realize that this model has many pros but also some pretty major cons. My only point is that it did affect my worldview. In my world, seniority, a killer  job title or a fancy suit won&#8217;t buy you my automatic respect. On the other hand, job well done, great vision, honesty, over achievement will!</p>
<p>Taking these few trains of thoughts in consideration, I started thinking about my own expectations for a good manager/leader. I figured that if I were able to do that, I could possibly be able to define a work environment where I could thrive and maybe one day become a good &#8220;manager/leader&#8221;.</p>
<p>I&#8217;ve always questioned my ability to be a good leader. While most of the time, I have an opinion and can easily decide what I think should be done, I have a hard time relating to people who can&#8217;t see the &#8220;big picture&#8221;. While I usually can get decent results, I&#8217;m aware that it can unfortunately sometime be at the cost of a few bruised egos. I also know I have high expectations for myself and for others and I have a hard time understanding how some people can be ok with the &#8220;status-quo&#8221;. I&#8217;m a perfectionist who is only happy when he outperforms his previous achievement. I was raised to challenge and always push myself further, focusing on concrete end-results and achieved goals. And to be honest, that&#8217;s what I enjoy. But I also know for a fact, that many people are not like that and I can&#8217;t blame them for looking at things from a different angle and not sharing the same motivations. Furthermore, I know that most people actually don&#8217;t have the same driven temperament and that&#8217;s why I&#8217;ve questioned my abilities to lead others.</p>
<p>However, different temperaments can work together as long as there is respect. And by respect, I mean that everyone feel that they were being heard and know that their input was considered and addressed even though the outcome might not be as hoped for. But for respect to happen, you first need trust. And when people trust each other, Lencioni explains that <em>&#8220;people don&#8217;t hold back one with another. They are unafraid to air their dirty laundry. They admit their mistakes, their weaknesses, and their concerns without fear of reprisal&#8221;</em>. I think that as simple as it seems, it is the key to a successful team. A good leader should be able to create such an atmosphere where people can trust each other. In fact, I think that if a manger/leader/executive can manage to build trust as defined earlier, his technical skills or lack of vision don&#8217;t matter as much. He/she will be able to rely on people he trusts to help him make the right decisions. Of course, there is much more than to be a good leader, but I think that with this base, great things can be built, and without it, a much greater effort is required to get some good results.</p>
<p>Based on my findings, I think that I need to work on my communication so others don&#8217;t feel that they have to hold back and make sure everyone feels that their opinions were considered and addressed. To do that a key element is to admit my mistakes and weaknesses and asking others to help me improve. That&#8217;s it, sorry for the boring, not technical post. I promise the next one will have at least a code sample.</p>
]]></content:encoded>
			<wfw:commentRss>http://merbist.com/2011/10/11/about-management/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to &#8211; cross domain ajax to a Ruby app</title>
		<link>http://merbist.com/2011/09/14/how-to-cross-domain-ajax-in-a-ruby-app/</link>
		<comments>http://merbist.com/2011/09/14/how-to-cross-domain-ajax-in-a-ruby-app/#comments</comments>
		<pubDate>Thu, 15 Sep 2011 00:11:41 +0000</pubDate>
		<dc:creator>Matt Aimonetti</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[html5]]></category>

		<guid isPermaLink="false">http://merbist.com/?p=1133</guid>
		<description><![CDATA[In some cases, you might have a bunch of apps running on different domains/subdomains and/or ports and you would like to make ajax requests between these services. The problem is that browsers wouldn&#8217;t let you make such requests because of the Same Origin Policy which only allowed them to make request to resources within the same domain. [...]]]></description>
			<content:encoded><![CDATA[<p>In some cases, you might have a bunch of apps running on different domains/subdomains and/or ports and you would like to make ajax requests between these services. The problem is that browsers wouldn&#8217;t let you make such requests because of the Same Origin Policy which only allowed them to make request to resources within the same domain.</p>
<p>However, most browsers (IE 8+, Firefox 3.5+, Safari 4+, Chrome) implement a simple way to allow cross domain requests as defined in this <a href="http://www.w3.org/TR/cors/">w3C document</a>.</p>
<p>Of course, if your users have an old version of their browser, you  might have to look into jsonp or something else such as cheating by using iframes &amp; setting document.domain. Let&#8217;s pretend for a minute that 100% of your users are on Chrome. The only thing you need to do is set a response header listing the accepted domains or &#8220;*&#8221; for all. A simple Rack middleware to do that would look like that.</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> XOriginEnabler
  ORIGIN_HEADER = <span style="color:#996600;">&quot;Access-Control-Allow-Origin&quot;</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> initialize<span style="color:#006600; font-weight:bold;">&#40;</span>app, accepted_domain=<span style="color:#996600;">&quot;*&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0066ff; font-weight:bold;">@app</span> = app
    <span style="color:#0066ff; font-weight:bold;">@accepted_domain</span> = accepted_domain
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> call<span style="color:#006600; font-weight:bold;">&#40;</span>env<span style="color:#006600; font-weight:bold;">&#41;</span>
    status, header, body = <span style="color:#0066ff; font-weight:bold;">@app</span>.<span style="color:#9900CC;">call</span><span style="color:#006600; font-weight:bold;">&#40;</span>env<span style="color:#006600; font-weight:bold;">&#41;</span>
    header<span style="color:#006600; font-weight:bold;">&#91;</span>ORIGIN_HEADER<span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0066ff; font-weight:bold;">@accepted_domain</span>
    <span style="color:#006600; font-weight:bold;">&#91;</span>status, header, body<span style="color:#006600; font-weight:bold;">&#93;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>And to use the middleware you would need to set it for use:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">use XOriginEnabler</pre></div></div>

<p>To enable all requests from whatever origin, or pass the white listed domain(s) as shown below.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">use XOriginEnabler, <span style="color:#996600;">&quot;demo.mysite.com demo.mysite.fr demo.techcrunch.com&quot;</span></pre></div></div>

<p>For a full featured middleware, see <a href="https://github.com/cyu/rack-cors">this project</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://merbist.com/2011/09/14/how-to-cross-domain-ajax-in-a-ruby-app/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Ruby optimization example and explanation</title>
		<link>http://merbist.com/2011/09/05/ruby-optimization-example-and-explaination/</link>
		<comments>http://merbist.com/2011/09/05/ruby-optimization-example-and-explaination/#comments</comments>
		<pubDate>Mon, 05 Sep 2011 22:58:21 +0000</pubDate>
		<dc:creator>Matt Aimonetti</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[scalability]]></category>

		<guid isPermaLink="false">http://merbist.com/?p=1124</guid>
		<description><![CDATA[Recently I wrote a small DSL that allows the user to define some code that then gets executed later on and in different contexts. Imagine something like Sinatra where each route action is defined in a block and then executed in context of an incoming request. The challenge is that blocks come with their context and [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I wrote a small DSL that allows the user to define some code that then gets executed later on and in different contexts. Imagine something like Sinatra where each route action is defined in a block and then executed in context of an incoming request.</p>
<p>The challenge is that blocks come with their context and you can&#8217;t execute a block in the context of another one.</p>
<p>Here is a reduction of the challenge I was trying to solve:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> SolutionZero
  <span style="color:#9966CC; font-weight:bold;">def</span> initialize<span style="color:#006600; font-weight:bold;">&#40;</span>origin, <span style="color:#006600; font-weight:bold;">&amp;</span>block<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0066ff; font-weight:bold;">@origin</span> = origin
    <span style="color:#0066ff; font-weight:bold;">@block</span> = block
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> dispatch
    <span style="color:#0066ff; font-weight:bold;">@block</span>.<span style="color:#9900CC;">call</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
SolutionZero.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">42</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#0066ff; font-weight:bold;">@origin</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#006666;">1</span> <span style="color:#006600; font-weight:bold;">&#125;</span>.<span style="color:#9900CC;">dispatch</span>
<span style="color:#008000; font-style:italic;"># undefined method `+' for nil:NilClass (NoMethodError)</span></pre></div></div>

<p>The problem is that the block refers to the @origin instance variable which is not available in its context.<br />
My first workaround was to use instance_eval:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> SolutionOne
  <span style="color:#9966CC; font-weight:bold;">def</span> initialize<span style="color:#006600; font-weight:bold;">&#40;</span>origin, <span style="color:#006600; font-weight:bold;">&amp;</span>block<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0066ff; font-weight:bold;">@origin</span> = origin
    <span style="color:#0066ff; font-weight:bold;">@block</span> = block
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> dispatch
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">instance_eval</span> <span style="color:#006600; font-weight:bold;">&amp;</span>@block
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
SolutionOne.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">40</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#0066ff; font-weight:bold;">@origin</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#006666;">2</span><span style="color:#006600; font-weight:bold;">&#125;</span>.<span style="color:#9900CC;">dispatch</span>
<span style="color:#008000; font-style:italic;"># 42</span></pre></div></div>

<p>My workaround worked fine, since the block was evaluated in the context of the instance and therefore the @origin ivar is made available to block context. Technically, I was good to go, but I wasn&#8217;t really pleased with this solution. First using instance_eval often an indication that you are trying to take a shortcut. Then having to convert my block stored as a block back into a proc every single dispatch makes me sad. Finally, I think that this code is probably not performing as well as it could, mainly due to unnecessary object allocations and code evaluation.<br />
I did some benchmarks replacing <a title="instance_eval" href="https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1323" target="_blank">instance_eval</a> by <a title="instance_exec" href="https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1355" target="_blank">instance_exec</a> since looking at the C code, instance_exec should be slightly faster. Turns out, it is not so I probably missed something when reading the implementation code.</p>
<p>I wrote some more benchmarks and profiled a loop of 2 million dispatches (only the #disptach method call on the same object). The GC profiler report showed that the GC was invoked 287 times and each invocation was blocking the execution for about 0.15ms.<br />
Using Ruby&#8217;s <a href="http://ruby-doc.org/core/classes/ObjectSpace.html#M001526" target="_blank">ObjectSpace</a> and <a href="http://ruby-doc.org/core/classes/GC.html#M001373" target="_blank">disabling the GC</a> during the benchmark, I could see that each loop allocates an object of type T_NODE which is more than likely our @block ivar converted back into a block. This is quite a waste. Furthermore, having to evaluate our block in a different context every single call surely isn&#8217;t good for performance.</p>
<p>So instead of doing the work at run time, why not doing it at load time? By that I mean that we can optimize the #dispatch method if we could &#8220;precompile&#8221; the method body instead of &#8220;proxying&#8221; the dispatch to an instance_eval call. Here is the code:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> SolutionTwo
  <span style="color:#9966CC; font-weight:bold;">def</span> initialize<span style="color:#006600; font-weight:bold;">&#40;</span>origin, <span style="color:#006600; font-weight:bold;">&amp;</span>block<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0066ff; font-weight:bold;">@origin</span> = origin
    implementation<span style="color:#006600; font-weight:bold;">&#40;</span>block<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  private
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> implementation<span style="color:#006600; font-weight:bold;">&#40;</span>block<span style="color:#006600; font-weight:bold;">&#41;</span>
    mod = <span style="color:#9966CC; font-weight:bold;">Module</span>.<span style="color:#9900CC;">new</span>
    mod.<span style="color:#9900CC;">send</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:define_method</span>, <span style="color:#ff3333; font-weight:bold;">:dispatch</span>, block<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">extend</span> mod
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
SolutionTwo.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">40</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#0066ff; font-weight:bold;">@origin</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#006666;">2</span><span style="color:#006600; font-weight:bold;">&#125;</span>.<span style="color:#9900CC;">dispatch</span>
<span style="color:#008000; font-style:italic;"># 42</span></pre></div></div>

<p>This optimization is based on the fact that the benchmark (and the real life usage) creates the instance once and then calls #dispatch many times. So by making the initialization of our instance a bit slower, we can drastically improve the performance of the method call. We also still need to execute our block in the right context. And finally, each instance might have a different way to dispatch since it is defined dynamically at initialization. To work around all these issues, we create a new module on which we define a new method called dispatch and the body of this method is the passed block. Then we simply our instance using our new module.</p>
<p>Now every time we call #dispatch, a real method is dispatched which is much faster than doing an eval and no objects are allocated. Running the profiler and the benchmarks script used earlier, we can confirm that the GC doesn&#8217;t run a single time and that the optimized code runs 2X faster!</p>
<p>&nbsp;</p>
<p>Once again, it&#8217;s yet another example showing that you <a href="http://merbist.com/2010/07/29/object-allocation-why-you-should-care/" target="_blank">should care about object allocation</a> when dealing with code in the critical path. It also shows how to work around the block bindings. Now, it doesn&#8217;t mean that you have to obsess about object allocation and performance, even if my last implementation is 2X faster than the previous, we are only talking about a few microseconds per dispatch. That said microseconds do add up and creating too many objects will slow down even your faster code since the GC will stop-the-world as its cleaning up your memory. In real life, you probably don&#8217;t have to worry too much about low level details like that, unless you are working on a framework or sharing your code with others. But at least you can learn and understand why one approach is faster than the other, it might not be useful to you right away, but if you take programming as a craft, it&#8217;s good to understand how things work under the hood so you can make educated decisions.<br />
&nbsp;</p>
<h3>Update:</h3>
<p>@apeiros in the comments suggested a solution that works &#038; performs the same as my solution, but is much cleaner:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> SolutionTwo
  <span style="color:#9966CC; font-weight:bold;">def</span> initialize<span style="color:#006600; font-weight:bold;">&#40;</span>origin, <span style="color:#006600; font-weight:bold;">&amp;</span>block<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0066ff; font-weight:bold;">@origin</span> = origin
    define_singleton_method<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:dispatch</span>, block<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">if</span> block_given?
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://merbist.com/2011/09/05/ruby-optimization-example-and-explaination/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>First step in scaling a web site: HTTP caching</title>
		<link>http://merbist.com/2011/07/11/first-step-in-scaling-a-web-site-http-caching/</link>
		<comments>http://merbist.com/2011/07/11/first-step-in-scaling-a-web-site-http-caching/#comments</comments>
		<pubDate>Mon, 11 Jul 2011 18:21:02 +0000</pubDate>
		<dc:creator>Matt Aimonetti</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Misc]]></category>
		<category><![CDATA[Software Design]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[http cache]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[scalability]]></category>
		<category><![CDATA[scaling]]></category>
		<category><![CDATA[varnish]]></category>

		<guid isPermaLink="false">http://merbist.com/?p=1094</guid>
		<description><![CDATA[Today my friend Patrick Crowley and I were talking about scaling his website: http://cinematreasures.org since an article covering his work will soon be published in a very popular newspaper. Patrick&#8217;s site is hosted on Heroku which comes by default with Varnish caching enabled. The challenge is that a lot of people using the Rails framework are used [...]]]></description>
			<content:encoded><![CDATA[<p>Today my friend <a title="Patrick Crowley" href="http://twitter.com/mokolabs" target="_blank">Patrick Crowley</a> and I were talking about scaling his website: <a title="Cinema Treasures" href="http://cinematreasures.org/" target="_blank">http://cinematreasures.org</a> since an article covering his work will soon be published in a very popular newspaper. Patrick&#8217;s site is hosted on <a title="Heroku" href="http://www.heroku.com/" target="_blank">Heroku</a> which comes by default with <a title="Varnish" href="https://www.varnish-cache.org/" target="_blank">Varnish caching</a> enabled.</p>
<p>The challenge is that a lot of people using the Rails framework are used to doing page caching instead of relying on HTTP caching, even though this feature was added a long time ago. The major problem with page caching is that it doesn&#8217;t scale that well as soon as you run more than one server. Indeed you would need to store the page content to a shared drive between your servers or use memcached and do some work to avoid hitting your app every single time. On the other hand, HTTP caching is extremely easy to handle at the application level and it will dramatically reduce the amount of requests hitting your app. Let me explain a little more about HTTP caching.</p>
<p>Ryan Tomako wrote an <a title="HTTP caching" href="http://tomayko.com/writings/things-caches-do" target="_blank">excellent post</a> about the details of caching, I strongly recommend you <a title="HTTP Caching" href="http://tomayko.com/writings/things-caches-do" target="_blank">read it</a>. In a nutshell, the HTTP caching layer (usually) seats before your application layer and allows you, the developer to store some responses that can be send back to the users based on optional conditions. That might still seem vague, let&#8217;s take a concrete example. If you look at <a href="http://cinematreasures.org" target="_blank">http://cinematreasures.org</a>&#8216;s home page you can see that it&#8217;s an agglomerate of various information:</p>
<p style="text-align: center;"><a href="http://cinematreasures.org"><img class="aligncenter" title="CinemaTreasures homepage" src="https://img.skitch.com/20110709-dnxjhikxr14tdr7e35n97madhn.jpg" alt="CinemaTreasures homepage" width="606" height="568" /></a></p>
<p>And the bottom of the page contains even more dynamic data such as the popular movie theater photos, latest movie theater videos and latest tweets. One might look at that and say that this page can&#8217;t really be cached and that the caching should be done at the model layer (i.e. cache the data coming from the database). I would certainly agree that caching the data layer is probably a good idea, but you shouldn&#8217;t start by that. In fact without caching, this page renders fast enough. The problem is when someone like <a href="http://rogerebert.suntimes.com/" target="_blank">Roger Ebert</a> tweets about <a title="Roger Ebert - Cinema Treasures" href="http://twitter.com/#!/ebertchicago/status/85912164648497152" target="_blank">CinemaTreasures</a> the load on the app peaks significantly. At the point, the amount of concurrent connections your app can handle gets put to the challenge. Even though your page load is &#8220;fast enough&#8221;, requests will queue up and some will eventually time out. That&#8217;s actually a perfect case of HTTP caching.</p>
<p>What we want to do in that case is to cache a version of the home page in Varnish for 60 seconds. During that time, all requests coming to the site, will be served by Varnish and will all get the same cached content. That allows our servers to handle the non cached requests and therefore increase our throughput. What&#8217;s even better, is that if a user refreshes the home page in his/her browser during the first 60 seconds the requests won&#8217;t even make it all the way to our servers. All of that thanks to conditions set on the response. The first user hitting the HTTP cache layer (Varnish in this case) won&#8217;t find a fresh cached response, so varnish will forward the request to our application layer which will send back the homepage to varnish and tell Varnish that this content is good for a full minute so please don&#8217;t ask for it again until a minute from now. Varnish serves this response to the users&#8217; browser and let the browser know that the server said that the response was good enough for a minute so don&#8217;t bother asking for it again. But now, if during these 60 seconds another user comes in, he will hit Varnish and Varnish will have the cached response from the first user and because the cache is still fresh (it&#8217;s not been 60 seconds since the first request) and the cache is public, then the same response will be sent to the second user.</p>
<p>As you can see, the real strength of HTTP caching is the fact that it&#8217;s a conditional caching. It&#8217;s based on the request&#8217;s URL and some &#8220;flags&#8221; set in the request/response headers.</p>
<p>Setting these conditions in your app is actually very simple since you just need to set the response&#8217;s headers. If you are using a Ruby framework you will more than likely have access to the request object via the &#8220;request&#8221; method and you can set the headers directly like that: &#8220;<span class="Apple-style-span" style="font-family: Consolas, Monaco, monospace; font-size: 12px; line-height: 18px; white-space: pre;">response.headers['Cache-Control'] = &#8216;public, max-age=60&#8242;&#8221;</span>.<br />
In Rails, you can actually use a helper method instead: <span class="Apple-style-span" style="font-family: Consolas, Monaco, monospace; font-size: 12px; line-height: 18px; white-space: pre;">expires_in 1.minute, :public => true</span>.</p>
<p>You might have a case where you HAVE TO serve fresh content if available and can&#8217;t serve stale cached content even for a few seconds. In this case, you can rely on the Etag header value. The Etag is meant to validate the freshness of a cached response. Think of it as a signature (unique ID) that is set on the response and used by the client (or cache layer) to see if the server response has changed or not. The way it works is that the client keeps track of the Etag received for each request (attached to the cached response) and then sends it with the next requests. The HTTP layer or application sees the Etag in the request and can check if it is still valid and the content didn&#8217;t change. If that&#8217;s the case, an empty response can be sent with a special HTTP status code (304) to let know the client that the old cached value is still good to be used.  Rails has a helper called &#8220;stale?&#8221; that helps you do the Etag/last modified check and allows you to not fetch all the objects from the database by doing a cheap check on an attribute (For instance you can check the updated_at value and use that as a condition to pull an object and its relationships).</p>
<p>So I explain HTTP caching, I often hear people telling me: &#8220;that&#8217;s great Matt, but you know what, that won&#8217;t work for us because we have custom content that we display specifically to our users&#8221;. So in that case, you can always set the Cache-Control header to private which will only cache the response in the client&#8217;s browser and not the cache layer. That&#8217;s good to some extent, but it can definitely be improved by rethinking a bit your view layer. In most web apps, the page content is rendered by server side code (Rails, Django, node.js, PHP..) and sent to the user all prepared for him. There are a few challenges with this approach, the biggest one is that the server has to wait until everything is ready (all data fetched, view rendered etc&#8230;) before sending back a response and before the client&#8217;s browser can start rendering (there are ways to chunk the response but that&#8217;s besides the scope of this post). The other is that the same expensive content has to be calculated/rendered for two different users because you might be inserting the username of the current user at the top of the page for instance. A classic way to deal with that is often to use fragment caching, where the expensive rendering is cached and reused by different requests. That&#8217;s good but if the only reason to do that is because we are displaying some user specific data, there is a simpler way: async page rendering. The concept is extremely simple: remove all user specific content from the rendered page and then inject the user content in a second step once the page is displayed. The advantage is that now the full page can be cached in Varnish (or Squid or whatever you use for HTTP caching). To inject the user content, the easiest way is to use JavaScript.</p>
<p>Let&#8217;s stay on CinemaTreasures, when you&#8217;re logged in, the username is shown on the top of each page:</p>
<div class="wp-caption aligncenter" style="width: 584px"><img title="cinema treasures Login" src="https://img.skitch.com/20110710-mh5tqxuw1txf9kppn1smkkarrs.jpg" alt="" width="574" height="140" /><p class="wp-caption-text">Once logged in, the username is displayed on all pages</p></div>
<p>The only things that differs from the page rendered when the user is not logged in and when he is, are these 2 links and an avatar. So let&#8217;s write some code to inject that after rendering the page.</p>
<p>In Rails, in the sessions controller or whatever code logs you in, you need to create a new cookie containing the username:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">cookies<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:username</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#006600; font-weight:bold;">&#123;</span>
         <span style="color:#ff3333; font-weight:bold;">:value</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> session<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:username</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
         <span style="color:#ff3333; font-weight:bold;">:expires</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">2</span>.<span style="color:#9900CC;">days</span>.<span style="color:#9900CC;">from_now</span>,
         <span style="color:#ff3333; font-weight:bold;">:domain</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;.cinematreasures.org&quot;</span>
       <span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>

<p>As you can see, we don&#8217;t store the data in the session cookie and the data won&#8217;t be encrypted. You need to be careful that someone changing his cookie value can&#8217;t access data he/should shouldn&#8217;t. But that&#8217;s a different discussion. Now that the cookie is set, we can read it from JavaScript when the page is loaded.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">document.<span style="color: #660066;">observe</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;dom:loaded&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  displayLoggedinUserLinks<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> readCookie<span style="color: #009900;">&#40;</span><span style="color: #000066;">name</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #003366; font-weight: bold;">var</span> nameEQ <span style="color: #339933;">=</span> <span style="color: #000066;">name</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;=&quot;</span><span style="color: #339933;">;</span>
     <span style="color: #003366; font-weight: bold;">var</span> ca <span style="color: #339933;">=</span> document.<span style="color: #660066;">cookie</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">';'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> ca.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #003366; font-weight: bold;">var</span> c <span style="color: #339933;">=</span> ca<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>c.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #3366CC;">' '</span><span style="color: #009900;">&#41;</span> c <span style="color: #339933;">=</span> c.<span style="color: #660066;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span>c.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>c.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span>nameEQ<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> c.<span style="color: #660066;">substring</span><span style="color: #009900;">&#40;</span>nameEQ.<span style="color: #660066;">length</span><span style="color: #339933;">,</span>c.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span>
     <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> displayLoggedinUserLinks<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> username            <span style="color: #339933;">=</span> readCookie<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'username'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> loginLink           <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'login'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> logout              <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'logout'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>username <span style="color: #339933;">==</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    loginLink.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    logout.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">// user is logged in and we have his/her username</span>
    loginLink.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>userGreetings<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> userGreetings.<span style="color: #660066;">update</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&lt;span id='username'&gt;username&lt;/span&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
    logout.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    showAvatar<span style="color: #009900;">&#40;</span>username<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The code above doesn&#8217;t do much, once the DOM is loaded, the displayLoggedinUserLinks() function gets trigger. This function reads the cookie via the readCookie() function and if a username is found, the login link is hidden, the user name is displayed, as well as the logout link and the avatar. (You can also use a jQuery cookie plugin to handle the cookie, but this is an old example using Prototype, replace the code accordingly)<br />
When the user logs out, we just need to delete the username cookie and the cached page will be rendered properly. In Rails, you would do delete the cookie like that: <span class="Apple-style-span" style="font-family: Consolas, Monaco, monospace; font-size: 12px; line-height: 18px; white-space: pre;">cookies.delete(&#8216;username&#8217;)</span>.<br />
Quite often you might even want to make an Ajax call to get some information such as the number of user messages or notifications. Using jQuery or whatever JS framework you fancy you can do that once the page is rendered. Here is an example, on this page, you can see the learderboards for MLB The Show. The leaderboards don&#8217;t change that often, especially the overall leaderboards so they can be cached for a little while, however the player&#8217;s presence can change anytime. The smart way to deal with that, would be to cache the  leaderboards for a few seconds/minutes and make an ajax call to a presence service passing it a list of user ids collected from the DOM. The service called via Ajax could also be cached  depending on the requirements.</p>
<p>Now there is one more problem that people using might encouter: flash notices. For those of you not familiar with Rails, flash notices are messages set in the controller and passed to the view via the session (at least last time I checked). The problem happens if I&#8217;m the home page isn&#8217;t cached anymore and I logged in which redirects me to the home page with a flash message like so:</p>
<p><img class="aligncenter" title="flash message" src="https://img.skitch.com/20110710-1u6dn8rrc6r62rsg6niphhd2pi.jpg" alt="" width="990" height="219" /></p>
<p>The problem is that the message is part of the rendered page and now for 60 seconds, all people hitting the home page will get the same message. This is why you would want to write a helper that would put this message in a custom cookie that you&#8217;d pull JS and then delete once displayed. You could use a helper like that to set the cookie:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">def</span> flash_notice_cookie<span style="color:#006600; font-weight:bold;">&#40;</span>msg, expiration=<span style="color:#0000FF; font-weight:bold;">nil</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  cookies<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:flash_notice</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#006600; font-weight:bold;">&#123;</span>
    <span style="color:#ff3333; font-weight:bold;">:value</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> msg,
    <span style="color:#ff3333; font-weight:bold;">:expires</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> expiration <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#006666;">1</span>.<span style="color:#9900CC;">minutes</span>.<span style="color:#9900CC;">from_now</span>,
    <span style="color:#ff3333; font-weight:bold;">:domain</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;.cinematreasures.com&quot;</span>
   <span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>And then add a function called when the DOM is ready which loads the message and injects it in the DOM. Once the cookie read, delete it so the message isn&#8217;t displayed again.</p>
<p>&nbsp;</p>
<p>So there you have it, if you follow these few steps, you should be able to handle easily 10x more traffic without increasing hardware or making any type of crazy code change. Before you start looking into memcached, redis, cdns or whatever, consider HTTP caching and async DOM manipulation. Finally, note that if you can&#8217;t use Varnish or Squid, you can very easily setup <a title="Rack Cache" href="http://rtomayko.github.com/rack-cache/" target="_blank">Rack-Cache</a> locally and share the cache via memcached. It&#8217;s also a great way to test locally.</p>
<hr />
<strong>Update:</strong> CinemaTreasures was updated to use HTTP caching as described above. The hosting cost is now half of what it used to be and the throughput is actually higher which offers a better protection against peak traffic.</p>
<hr />
<p>&nbsp;</p>
<p>External resources:</p>
<ul>
<li><a href="http://tomayko.com/writings/things-caches-do" target="_blank">http://tomayko.com/writings/things-caches-do</a></li>
<li><a title="HTTP Caching at Heroku" href="http://devcenter.heroku.com/articles/http-caching" target="_blank">HTTP Caching at Heroku</a></li>
<li><a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html" target="_blank">W3 caching protocol </a></li>
<li><a href="http://rtomayko.github.com/rack-cache/" target="_blank">Rack-Cache middleware</a></li>
<li><a href="http://www.nolanevans.com/2011/03/optimizing-your-rails-site-with-http.html" target="_blank">Blog post covering HTTP Caching/Varnish/Rails</a></li>
<li><a href="http://plugins.jquery.com/project/Cookie" target="_blank">jQuery cookie plugin</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://merbist.com/2011/07/11/first-step-in-scaling-a-web-site-http-caching/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Go&#8217;s reflection example</title>
		<link>http://merbist.com/2011/06/27/golang-reflection-exampl/</link>
		<comments>http://merbist.com/2011/06/27/golang-reflection-exampl/#comments</comments>
		<pubDate>Mon, 27 Jun 2011 20:12:32 +0000</pubDate>
		<dc:creator>Matt Aimonetti</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://merbist.com/?p=1084</guid>
		<description><![CDATA[The Go Programming language is really cool language by Google. According to the sales pitch, it&#8217;s a &#8220;fast, statically typed, compiled language that feels like a dynamically typed, interpreted language&#8221;. Well, if you are like me, you don&#8217;t trust sales pitches because you know that people writing them dont&#8217; care about you, they care about [...]]]></description>
			<content:encoded><![CDATA[<p>The <a title="Go Lang" href="http://golang.org/" target="_blank">Go Programming language</a> is really cool language by Google. According to the sales pitch, it&#8217;s a <strong><em>&#8220;fast, statically typed, compiled language that feels like a dynamically typed, interpreted language&#8221;</em></strong>. Well, if you are like me, you don&#8217;t trust sales pitches because you know that people writing them dont&#8217; care about you, they care about their product. However cynical you are, you still have to check the facts. So here is a quick demonstration showing how to use Go&#8217;s reflection feature.</p>
<p>Installing Go is actually really straight forward on a Mac, and slightly harder on Linux, check <a title="golang install" href="http://golang.org/doc/install.html" target="_blank">this guide </a>to see how to build Go in a few minutes.</p>
<p>Once all setup, you might want to read the documentation to see how to code in Go. Go is actually a kind of nice version of C with a<a title="Golang specs" href="http://golang.org/doc/go_spec.html" target="_blank"> simplified syntax</a>, no header files, really fast compilation time, a garbage collector and a <a title="golang types and interfaces" href="http://golang.org/doc/effective_go.html?#interfaces_and_types" target="_blank">simple way to approach object inheritance</a> without turning in the complicated mess C++ is. The language is designed around the concept of <a title="Golang concurrency" href="http://golang.org/doc/effective_go.html?h=goroutines#concurrency" target="_blank">goroutines, a very nice way to handle concurrency</a>. It also has some features that Rubyists, Pythonistas and Javascripters wouldn&#8217;t want to live without such as closures and some they probably wish they had such as <a title="Go Defer" href="http://golang.org/doc/effective_go.html?#defer" target="_blank">defer</a>. But of the things we are used to with dynamic languages is the concept of reflection. In a nutshell, at runtime, your code can reflect on the type of a given object and let the developer act accordingly. Depending on your programming background that might be obvious or you might not see the value. To be honest, that&#8217;s not the question here. What I&#8217;m interested in showing you is how it works.</p>
<p>For the sake of this demo, let&#8217;s pretend we want to have a &#8220;Dish&#8221; data model, each instance of the &#8220;Dish&#8221; type will have a few attributes, an id, a name, an origin and a custom query which really is a function that we store as an attribute. Here is how we would represent that model in Go:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Data Model</span>
type Dish <span style="color: #993333;">struct</span> <span style="color: #009900;">&#123;</span>
  Id  <span style="color: #993333;">int</span>
  Name string
  Origin string
  Query func<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This is more or less the equivalent of the following Ruby code:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> Dish
  attr_accessor <span style="color:#ff3333; font-weight:bold;">:id</span>, <span style="color:#ff3333; font-weight:bold;">:name</span>, <span style="color:#ff3333; font-weight:bold;">:origin</span>, <span style="color:#ff3333; font-weight:bold;">:query</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Ruby works slightly differently in the sense that defining attribute accessors create getters and setter methods but doesn&#8217;t technically create instance variables until they are used. Here is what I mean:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">shabushabu = Dish.<span style="color:#9900CC;">new</span>
shabushabu.<span style="color:#9900CC;">instance_variables</span> <span style="color:#008000; font-style:italic;"># =&gt; []</span>
shabushabu.<span style="color:#9900CC;">name</span> = <span style="color:#996600;">&quot;Shabu-Shabu&quot;</span>
shabushabu.<span style="color:#9900CC;">instance_variables</span> <span style="color:#008000; font-style:italic;"># =&gt; [&quot;@name&quot;]</span>
shabushabu.<span style="color:#9900CC;">origin</span> = <span style="color:#996600;">&quot;Japan&quot;</span>
shabushabu.<span style="color:#9900CC;">instance_variables</span> <span style="color:#008000; font-style:italic;"># =&gt; [&quot;@name&quot;, &quot;@origin&quot;]</span></pre></div></div>

<p>Another way of checking on the accessors is to check the methods defined on the object:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">shabushabu.<span style="color:#9900CC;">methods</span> <span style="color:#006600; font-weight:bold;">-</span> <span style="color:#CC00FF; font-weight:bold;">Object</span>.<span style="color:#9900CC;">new</span>.<span style="color:#9900CC;">methods</span>
<span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;name&quot;</span>, <span style="color:#996600;">&quot;name=&quot;</span>, <span style="color:#996600;">&quot;origin&quot;</span>, <span style="color:#996600;">&quot;origin=&quot;</span>, <span style="color:#996600;">&quot;id=&quot;</span>, <span style="color:#996600;">&quot;query&quot;</span>, <span style="color:#996600;">&quot;query=&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span></pre></div></div>

<p>But anyway, this post isn&#8217;t about Ruby, it&#8217;s about Go and what we would like is to reflect on an object of &#8220;Dish&#8221; type and see its attributes. The good news is that the Go language ships with a <a title="Golang reflect package" href="http://golang.org/pkg/reflect/">package to do just that</a>. Here is the full implementation:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">package main
&nbsp;
import<span style="color: #009900;">&#40;</span>
  <span style="color: #ff0000;">&quot;fmt&quot;</span>
  <span style="color: #ff0000;">&quot;reflect&quot;</span>
<span style="color: #009900;">&#41;</span>
&nbsp;
func main<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">// iterate through the attributes of a Data Model instance</span>
  <span style="color: #b1b100;">for</span> name<span style="color: #339933;">,</span> mtype <span style="color: #339933;">:=</span> range attributes<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>Dish<span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    fmt.<span style="color: #202020;">Printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Name: %s, Type %s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> name<span style="color: #339933;">,</span> mtype.<span style="color: #202020;">Name</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Data Model</span>
type Dish <span style="color: #993333;">struct</span> <span style="color: #009900;">&#123;</span>
  Id  <span style="color: #993333;">int</span>
  Name string
  Origin string
  Query func<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Example of how to use Go's reflection</span>
<span style="color: #666666; font-style: italic;">// Print the attributes of a Data Model</span>
func attributes<span style="color: #009900;">&#40;</span>m interface<span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span>map<span style="color: #009900;">&#91;</span>string<span style="color: #009900;">&#93;</span>reflect.<span style="color: #202020;">Type</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  typ <span style="color: #339933;">:=</span> reflect.<span style="color: #202020;">TypeOf</span><span style="color: #009900;">&#40;</span>m<span style="color: #009900;">&#41;</span>
  <span style="color: #666666; font-style: italic;">// if a pointer to a struct is passed, get the type of the dereferenced object</span>
  <span style="color: #b1b100;">if</span> typ.<span style="color: #202020;">Kind</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> reflect.<span style="color: #202020;">Ptr</span><span style="color: #009900;">&#123;</span>
    typ <span style="color: #339933;">=</span> typ.<span style="color: #202020;">Elem</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// create an attribute data structure as a map of types keyed by a string.</span>
  attrs <span style="color: #339933;">:=</span> make<span style="color: #009900;">&#40;</span>map<span style="color: #009900;">&#91;</span>string<span style="color: #009900;">&#93;</span>reflect.<span style="color: #202020;">Type</span><span style="color: #009900;">&#41;</span>
  <span style="color: #666666; font-style: italic;">// Only structs are supported so return an empty result if the passed object</span>
  <span style="color: #666666; font-style: italic;">// isn't a struct</span>
  <span style="color: #b1b100;">if</span> typ.<span style="color: #202020;">Kind</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> reflect.<span style="color: #202020;">Struct</span> <span style="color: #009900;">&#123;</span>
    fmt.<span style="color: #202020;">Printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%v type can't have attributes inspected<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> typ.<span style="color: #202020;">Kind</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #b1b100;">return</span> attrs
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// loop through the struct's fields and set the map</span>
  <span style="color: #b1b100;">for</span> i <span style="color: #339933;">:=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> typ.<span style="color: #202020;">NumField</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span> <span style="color: #009900;">&#123;</span>
    p <span style="color: #339933;">:=</span> typ.<span style="color: #202020;">Field</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span>
      <span style="color: #b1b100;">if</span> <span style="color: #339933;">!</span>p.<span style="color: #202020;">Anonymous</span> <span style="color: #009900;">&#123;</span>
        attrs<span style="color: #009900;">&#91;</span>p.<span style="color: #202020;">Name</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> p.<span style="color: #202020;">Type</span>
      <span style="color: #009900;">&#125;</span>
     <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #b1b100;">return</span> attrs
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Unfortunately, my code highlighter doesn&#8217;t support the Go syntax, but GitHub does, so here is a <a title="Golang reflection" href="https://gist.github.com/1009629" target="_blank">pretty version</a>.</p>
<p>There are ways of running Go source code like Ruby or Python scripts but in this case, we&#8217;ll use the compiler &amp; linker provided with Go. I named my source file &#8220;example.go&#8221;, and here is how I compiled, linked and run it:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ 6g example.go <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> 6l example.6 <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> .<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">6</span>.out
Name: Origin, Type string
Name: Id, Type int
Name: Query, Type 
Name: Name, Type string</pre></div></div>

<p>As you can see each attribute is printed out with its name and type. The code might seem a bit odd if you never looked at Go before.<br />
Here is a quick rundown of the code:</p>
<p>In our main function, we create a new instance of type Dish on which we call attributes on. The call returns a map on which we iterate through and print the attribute name (key) and type (value).<br />
The attributes function is defined a bit below and and it takes any type of objects (empty interface) and returns a map, which is like a Hash or a Dictionary. The map has keys of String type and values of &#8220;Type&#8221; type. The &#8220;Type&#8221; type is defined in the reflect package. Inside the function, 23 then use the previously mentioned reflect package to check on the type and the name of each attribute and assign it to a map object. (note that I&#8217;m explicitly returning the map, but I could have done it in a more implicit way)</p>
<p>So there you go, that&#8217;s how you use reflection in Go. Pretty nifty and simple.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://merbist.com/2011/06/27/golang-reflection-exampl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sayonara Sony</title>
		<link>http://merbist.com/2011/06/10/sayonara-sony/</link>
		<comments>http://merbist.com/2011/06/10/sayonara-sony/#comments</comments>
		<pubDate>Fri, 10 Jun 2011 16:49:30 +0000</pubDate>
		<dc:creator>Matt Aimonetti</dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://merbist.com/?p=1038</guid>
		<description><![CDATA[It&#8217;s now official, I have resigned from Sony Computer Entertainment America. I was planning on posting this a bit later but since I was politely escorted out of the building by HR/security, I have more free time to let you know of my decision. Before you ask: No, my decision isn&#8217;t directly related to the [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;">It&#8217;s now official, I have resigned from Sony Computer Entertainment America.</p>
<p><a rel="attachment wp-att-1045" href="http://merbist.com/2011/06/10/sayonara-sony/playstation-logo/"><img class="aligncenter size-thumbnail wp-image-1045" title="playstation-logo" src="http://merbist.com/wp-content/uploads/2011/06/playstation-logo-150x150.png" alt="" width="150" height="150" /></a></p>
<p>I was planning on posting this a bit later but since I was politely escorted out of the building by HR/security, I have more free time to let you know of my decision. Before you ask: No, my decision isn&#8217;t directly related to the recent PSN/Sony security breach events and no, I don&#8217;t have your credit card number. More seriously, my decision boils down to something much simpler &amp; concrete: drive and passion.</p>
<p>The concept of drive is very well explained <a title="Dan Pink, Drive" href="http://www.youtube.com/watch?v=u6XAPnuFjJc" target="_blank">in this talk</a> by <a title="Dan Pink" href="http://www.danpink.com/" target="_blank">Dan Pink</a> and illustrated by <a href="http://www.thersa.org/" target="_blank">RSA</a>:</p>
<p><iframe width="560" height="349" src="http://www.youtube.com/embed/u6XAPnuFjJc" frameborder="0" allowfullscreen></iframe></p>
<p>As explained, it is proven that when doing cognitive tasks, there are 3 factors that lead to better performance &amp; personal satisfaction:</p>
<ul>
<li>Autonomy: engagement vs compliance</li>
<li>Mastery: get better at stuff</li>
<li>Purpose: be disruptive but make the world a better place</li>
</ul>
<p>&nbsp;</p>
<p>The challenge is that when you work for a big corporation, you rarely see these factors applied. The amount of red tape, management overhead, lack of recognition and accountability result in a low drive by most employees. I think it was the first time in my entire career that I was told by a manager to care less about the quality and end result of our products.</p>
<p>The second important concept that I think is critical when looking at your career is passion. This topic is very well covered in <a title="Chad Fowler" href="http://chadfowler.com/" target="_blank">Chad Fowler</a>&#8216;s book: <a title="The Passionate Programmer" href="http://pragprog.com/titles/cfcar2/the-passionate-programmer" target="_blank">The Passionate Programmer</a>.</p>
<p><a href="http://pragprog.com/titles/cfcar2/the-passionate-programmer"><img class="aligncenter" title="The Passionate Programmer" src="http://imagery.pragprog.com/products/137/cfcar2_xlargecover.jpg?1298589825" alt="" width="152" height="228" /></a>Here is a quote from Chad&#8217;s book:</p>
<blockquote><p>Fulfillment and happiness don’t (often) come by chance. They require thought, intention, action, and a willingness to change course when you’ve made mistakes. [...] It might be a technology or business domain that gets you excited. Or, on the other hand, it might be a specific technology or business domain that drags you down. Or a type of organization. Maybe you’re meant for small teams or big teams. Or rigid processes. Or agile processes. Whatever the mix, take some time to find yours. You can fake it for a while, but a lack of passion will catch up with you and your work.</p></blockquote>
<p>&nbsp;</p>
<p>It&#8217;s hard to summarize Chad&#8217;s book into just a few sentences, but what I got from his book is that if, for whatever reason, you lose your passion for your job, you should move on to another place where you can be passionate and excel. In my case, I&#8217;m still very much passionate about video game development but I find my passion seriously affected by an unhealthy work environment, bad communication and a lack of desire to change things in concrete ways. As the saying goes, <a href="http://www.google.com/search?q=people+don't+leave+jobs" target="_blank">&#8220;People don&#8217;t leave jobs&#8230;&#8221;</a></p>
<p>&nbsp;</p>
<h3>What&#8217;s next for me?</h3>
<p>If you are in the software industry you know that everybody is hiring and that there is a real shortage of talent out there. You probably also receive half a dozen emails per week from recruiters offering you &#8220;the best job ever&#8221; with an obscene salary. Well, I receive them too. But in this market, you and I can allow ourselves to be picky and to choose the right job for ourselves. By choosing the right job, we are going to be more passionate, more driven, more efficient and bring a lot more value to our employers, who, in return, will hopefully do everything they can to make sure we grow within the company with a strong desire to do even better. As I was considering what I would want to do if I were to leave Sony, I came up with a few ideas about a job:</p>
<ul>
<li>I don&#8217;t want to live to work, but rather, work to live. (kind of an European cliché sentence)</li>
<li>It&#8217;s not about the job title.</li>
<li>It&#8217;s not about the pay check.</li>
<li>It&#8217;s not about how glamourous an industry  is.</li>
<li>What matters is :
<ul>
<li>the company culture.</li>
<li>the passion coming from the leaders.</li>
<li>the company&#8217;s ambitions.</li>
<li>how the company rewards and respects its employees.</li>
<li>the autonomy/trust given to the employees.</li>
<li>the purpose of the company and its potential to disrupt a market/change the world.</li>
<li>personal growth within the company.</li>
</ul>
</li>
</ul>
<p>&nbsp;</p>
<p>Writing this list helped me realize that I was definitely not in the right place and helped me create a list of criteria to define what kind of job I should be doing instead. As I was thinking about all that, I was reminded of this quote:</p>
<blockquote><p>&#8220;One should not pursue goals that are easily achieved. One must develop an instinct for what one can just barely achieve through one&#8217;s greatest efforts.&#8221; —Albert Einstein</p></blockquote>
<p>This is probably a personality trait, but I like/need to be at the edge of my confort zone. I need to learn new things, experience new challenges. I need to try to solve unsolved problems. So part of me needs a company with a rich culture, a great a vision and leadership, but another part also needs to be allowed to think creatively, to push the existing boundaries, to challenge myself and to try to achieve things through my greatest efforts.</p>
<p>The challenge is that over the last 5-7 years I have become a Ruby specialist. I have learned to understand and master the language, learning its pros/cons and what goes on &#8220;under the hood&#8221;. I have built small and huge solutions for various domain spaces on top of Ruby. I have shared my knowledge giving talks, books, blog posts. I have also spent a lot of time expanding my own computer science knowledge, looking into other programming languages, frameworks, designs. My job at Sony was interesting due to the fact that Ruby is used in a quite singular way with very specific problems and a lot of C/C++ interaction. So while it is true that I am a Ruby specialist, I don&#8217;t like that label. I don&#8217;t like it because it&#8217;s very limiting. My goal is to solve problems and quite often Ruby is a great tool for that, but for some problems, it is not. So I need a job where my expertise is helpful but would not limit my desire to learn new approaches, languages and skills.</p>
<p>And this is why I will soon start working as a <em>Code Alchemist in the LivingSocial R&amp;D&#8217;s lab</em>.</p>
<p><a rel="attachment wp-att-1044" href="http://merbist.com/2011/06/10/sayonara-sony/livingsocial-2/"><img class="aligncenter size-full wp-image-1044" title="livingsocial" src="http://merbist.com/wp-content/uploads/2011/06/livingsocial1.png" alt="" width="373" height="107" /></a></p>
<p>That might be a shocker at first glance. Going from working on video games to working for a daily-deal startup? It doesn&#8217;t seem like a very smart career move. To be honest, that was my first reaction. But LivingSocial&#8217;s VP of engineering is <a href="http://twitter.com/#!/chadfowler" target="_blank">Chad Fowler</a> (the author of The Passionate Programmer, mentioned earlier) and its VP of R&amp;D is <a href="http://en.wikipedia.org/wiki/Richard_Kilmer_(programmer)" target="_blank">Rich Kilmer</a>, InfoEther&#8217;s cofounder and recognized mad-scientist-coder. I&#8217;ve known Chad and Rich for many years, meeting at tech conferences that they organized or were invited to give talks to, and even getting to hack on some projects with Rich. So when they approached me to join them at LivingSocial, I wanted to know more about their own motivations, why I would be a good fit and how the company/job would rate against my list of criteria. We had long and honest discussions and the result is that I am excited to soon be working with one of the best teams I know of. More concretely, I will be working with <a href="http://twitter.com/#!/rich_kilmer" target="_blank">Rich</a>, <a title="Bruce Williams" href="http://twitter.com/#!/wbruce" target="_blank">Bruce</a> and <a title="Michael Buffington" href="http://twitter.com/#!/go" target="_blank">Michael</a> in helping LivingSocial revolutionize the local market. LivingSocial is a fast growing and successful company with a strong focus on creating a great experience for both customers and merchants. The company&#8217;s vision is well defined and the desire to change the world the way we know it is palpable. Most of the founders have a technical background, they value good engineering practices and have created a nice, positive company culture. Chad has some really awesome, passionate and talented engineers on his team (too many to mention), for whom I have a lot of respect and with whom I look forward to working with.  I also value the fact that LivingSocial trusts and values me enough to let me work remotely. This is very important for me because it shows that my new employer really wants to work with me, trusts me but also is willing to embrace the challenges of having a remote team if that&#8217;s what&#8217;s needed to create the &#8220;right team&#8221;. After looking more deeply at what I need and what LivingSocial is, I believe that I can assist LivingSocial in making a very positive change to the way small businesses around the world are run. And I am looking forward to this.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://merbist.com/2011/06/10/sayonara-sony/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>RubyConf 2010 &#8211; MacRuby talk</title>
		<link>http://merbist.com/2010/11/12/rubyconf-2010-macruby-talk/</link>
		<comments>http://merbist.com/2010/11/12/rubyconf-2010-macruby-talk/#comments</comments>
		<pubDate>Sat, 13 Nov 2010 00:00:51 +0000</pubDate>
		<dc:creator>Matt Aimonetti</dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://merbist.com/?p=832</guid>
		<description><![CDATA[This year I gave the traditional Apple&#8217;s MacRuby talk at RubyConf. My presentation focused on 2 axis: What&#8217;s new since last RubyConf Show some examples of how fun it is to hack with MacRuby Macruby &#8211; RubyConf Presentation 2010 View more presentations from Matt Aimonetti. MacRuby is currently at version 0.7.1 and version 0.8 is [...]]]></description>
			<content:encoded><![CDATA[<p>This year I gave the traditional Apple&#8217;s MacRuby talk at RubyConf.<br />
My presentation focused on 2 axis:</p>
<ul>
<li> What&#8217;s new since last RubyConf</li>
<li>Show some examples of how fun it is to hack with MacRuby</li>
</ul>
<div id="__ss_5760365" style="width: 425px;"><strong style="display: block; margin: 12px 0 4px;"><a title="Macruby - RubyConf Presentation 2010" href="http://www.slideshare.net/mattetti/macruby-rubyconf-presentation-2010">Macruby &#8211; RubyConf Presentation 2010</a></strong><object id="__sse5760365" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="355" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="src" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=macruby2010-101112175748-phpapp02&amp;stripped_title=macruby-rubyconf-presentation-2010&amp;userName=mattetti" /><param name="name" value="__sse5760365" /><param name="allowfullscreen" value="true" /><embed id="__sse5760365" type="application/x-shockwave-flash" width="425" height="355" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=macruby2010-101112175748-phpapp02&amp;stripped_title=macruby-rubyconf-presentation-2010&amp;userName=mattetti" name="__sse5760365" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<div style="padding: 5px 0 12px;">View more <a href="http://www.slideshare.net/">presentations</a> from <a href="http://www.slideshare.net/mattetti">Matt Aimonetti</a>.</div>
</div>
<p>MacRuby is currently at version 0.7.1 and version 0.8 is in preparation.<br />
Since last new a lot of things happened, here is a quick summary:</p>
<ul>
<li> Cocoa dev is now considered stable.  Apple gave its seal of approval, most of the bugs are fixed and it&#8217;s currently used on production projects and some apps were even submitted to the Mac App Store.</li>
</ul>
<ul>
<li> Ahead of Time compilation. This is quite a major improvement with many repercussions. Being to compile your Ruby source code means faster boot time and source obfuscation. Two major things to consider when you want to ship a desktop app.</li>
<li>Debugger. MacRuby now ships with its own debugger. Of course you can still use GDB and DTrace, but MacRuby&#8217;s debugger is really easy to use and very powerful.</li>
<li>Grand Central Dispatch support and wrapper API. Having to manage threads can be hard for both developers and for the machines having to run the developer code. GCD is an abstraction layer allowing developers to only focus on business logic without having to worry about the underlying details if you don&#8217;t want to. The end result is an optimum use of all the cores available on a machine and truly concurrent code. Two important notions when writing desktop apps.</li>
<li>ControlTower &#8211; A webserver for Rack apps written in MacRuby and using GCD for concurrency.</li>
<li>New rewritten and more efficient dispatcher. Practically that means that the dispatcher is now thread safe with a per thread cache.</li>
<li>RegExp lib switch from Oniguruma to ICU. This was quite a big change and it was required because Oniguruma isn&#8217;t thread safe and while C Ruby uses a Global Interpreter Lock. MacRuby on the other hand uses native POSIX threads running on their own non-locking, reentrant VM making thread safety critical.</li>
<li>More solid foundations &#8211; Some key classes we rewritten to improve performance and flexibility.</li>
<li>Support for C blocks &#8211; Objective-C has been supporting C blocks for a while and some Cocoa APIs require the use of blocks. MacRuby now allows you to use Ruby blocks and to pass them as C blocks. (new BridgeSupport required)</li>
<li>Sandboxing &#8211; For safety reasons, MacRuby allows you to now sandbox your applications. You can restrict your app from doing some potential dangerous things such as writing to disk, calling the system, accessing internet etc&#8230;</li>
<li>Mac App Store &#8211; This is not something done by the MacRuby team. But it directly affects MacRuby developers wanting to distribute their applications. Think about the exposure that you can app can have. Even if you have a web app, you can use WebKit to wrap it up, hook up a notification, add to that a local backup solution and geo location. Brilliant way to provide an even better user experience and better product exposure. All that really easily if you already know Ruby.</li>
</ul>
<p>To give an idea of what can be done I showed some code samples hopefully showing the cool hacking things one can play with:</p>
<ul>
<li>The first demo shows how to use the speech recognizer. The example is really sample you speak the name of someone and his/her picture shows up on screen. Just a few lines of code and you can start screaming commands to your TV to get it to change channel.</li>
<li>The second demo is an extremely simple Gowala client using CoreLocation. Yes, Mac desktop and laptops support geo location.</li>
<li>Another example of what you do is a sample letting you import all your twitter followers to your address book.</li>
<li>You can also use some of the low level OS features such as the Tokenizer. The next example showed how to extend Ruby and use a C function to detect the language of a string.</li>
<li>Finally, the last demo shows how to integrate a bluetooth device to control a HTML view via MacRuby and Javascript. All that in just a few lines of code!</li>
</ul>
<p>Basically, MacRuby is now mature and it&#8217;s time for hackers and people trying to get exposure to give it a try.</p>
]]></content:encoded>
			<wfw:commentRss>http://merbist.com/2010/11/12/rubyconf-2010-macruby-talk/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

