<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Rob Searles</title>
	
	<link>http://www.robsearles.com</link>
	<description>Musing on the business of and development for "The Web"</description>
	<lastBuildDate>Fri, 30 Mar 2012 14:09:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/RobSearles" /><feedburner:info uri="robsearles" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>EmacsWiki vs WikEmacs</title>
		<link>http://feedproxy.google.com/~r/RobSearles/~3/4c5xCopzBRs/</link>
		<comments>http://www.robsearles.com/2012/03/30/emacswiki-vs-wikemacs/#comments</comments>
		<pubDate>Fri, 30 Mar 2012 14:09:18 +0000</pubDate>
		<dc:creator>Rob Searles</dc:creator>
				<category><![CDATA[Emacs]]></category>
		<category><![CDATA[Opinion]]></category>

		<guid isPermaLink="false">http://www.robsearles.com/?p=649</guid>
		<description><![CDATA[Lot of fun stuff going on with the Emacs Wiki. Last week, Bozhidar Batsov wrote a controvertial post called Die EmacsWiki Die. Which made me think somewhat of Sideshow Bob, (especially as I&#8217;m in Germany and sometimes I get some Deutsch posts coming up on my reader). This sparked a flurry of debate, on HackerNews [...]]]></description>
			<content:encoded><![CDATA[<p>Lot of fun stuff going on with the Emacs Wiki.</p>
<p>Last week, Bozhidar Batsov wrote a controvertial post called <a href="http://batsov.com/articles/2012/03/20/die-emacswiki/" target="_blank">Die EmacsWiki Die</a>. Which made me think somewhat of <a href="http://www.youtube.com/watch?v=dMkzdn2TDuI" target="_blank">Sideshow Bob</a>, (especially as I&#8217;m in Germany and sometimes I get some Deutsch posts coming up on my reader). This sparked a flurry of debate, on <a href="https://news.ycombinator.com/item?id=3729372" target="_blank">HackerNews</a> and <a href="http://www.reddit.com/r/emacs/comments/r53cd/die_emacswiki_die/" target="_blank">Reddit</a> as well as a <a href="http://www.emacswiki.org/emacs/?2012-03-20" target="_blank">response from Alex Schroeder</a> , the creator and maintainer of EmacsWiki.</p>
<p>The result of all of this is a new Wiki: <a href="http://wikemacs.org/" target="_blank">WikEmacs</a> has now been <a href="http://batsov.com/articles/2012/03/26/wikemacs-the-other-emacs-wiki/" target="_blank">set up by Bozhidar</a>.</p>
<p>I&#8217;m not sure I agree with this. Yes the current wiki is a bit of a mess. Yes there are some outdated bits of information there, and some of it is incoherent. Yes it could be structured better, or use Markdown to help with the formatting.  But I can&#8217;t help but thinking it would be a huge mistake to disregard what it is, wipe the slate clean and start again. It reminds me of a Joel Spolsky article about &#8220;<a href="http://www.joelonsoftware.com/articles/fog0000000069.html" target="_blank">Things you should </a><a style="font-weight: bold;" href="http://www.joelonsoftware.com/articles/fog0000000069.html" target="_blank">never do</a>&#8220;. Whilst that article was obviously talking about software I feel that the same does apply to content.</p>
<p>Whilst a new wiki will start out with the best intentions, and to start off with it will be nice and clean and well structured etc, this is the same as most software projects. However, as we all know, as the project goes on, the code (or content) becomes legacy things can start to slip. Stuff is moved around, and new stuff added, and eventually the base is so large it becomes hard to navigate. Fast forward and you have a large unwieldy repository that someone new comes along, sees a huge mess so decides to start again from scratch.</p>
<p>Nope, in my mind the best thing to do is to refactor what is already there. And that&#8217;s exactly what I intend to help with.</p>
<img src="http://www.robsearles.com/?ak_action=api_record_view&id=649&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/RobSearles?a=4c5xCopzBRs:5GAR3Exg-Ys:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/RobSearles?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/RobSearles/~4/4c5xCopzBRs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.robsearles.com/2012/03/30/emacswiki-vs-wikemacs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.robsearles.com/2012/03/30/emacswiki-vs-wikemacs/</feedburner:origLink></item>
		<item>
		<title>Not Switching from Emacs to Vim</title>
		<link>http://feedproxy.google.com/~r/RobSearles/~3/QJpbdG78Wmo/</link>
		<comments>http://www.robsearles.com/2012/03/28/not-switching-from-emacs-to-vim/#comments</comments>
		<pubDate>Wed, 28 Mar 2012 14:52:26 +0000</pubDate>
		<dc:creator>Rob Searles</dc:creator>
				<category><![CDATA[Emacs]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[tmux]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://www.robsearles.com/?p=645</guid>
		<description><![CDATA[Following my last article about possibly making the heretical move to Vim from Emacs, I&#8217;ve been trying to use Vim as much as I can. I can now safely say that I will not be making the switch. There are a number of reasons to this. Firstly, and most importantly I can&#8217;t quite make the conceptual leap [...]]]></description>
			<content:encoded><![CDATA[<p>Following my last article about possibly <a href="http://www.robsearles.com/2012/03/20/switching-from-emacs-to-vim/">making the heretical move to Vim from Emacs</a>, I&#8217;ve been trying to use Vim as much as I can. I can now safely say that I will <strong>not</strong> be making the switch.</p>
<p>There are a number of reasons to this.</p>
<p>Firstly, and most importantly I can&#8217;t quite make the conceptual leap to modal editing. My brain understands that I need to hit &#8220;Esc&#8221; if I want to move around, or &#8220;i&#8221; if I then want to insert something, however my fingers completely ignore that fact. I just can&#8217;t seem to stop myself moving around and then starting to type straight away. Likewise, I just can&#8217;t seem to stop trying to move whilst I am writing. My pathetic intellect can&#8217;t cope with separating the two.</p>
<p>Secondly, the saying is true: &#8220;You don&#8217;t miss something till it&#8217;s gone&#8221;. I have discovered during my journey of using Vim that I actually really like Emacs. I like the fact that it has a calendar in there so I can quickly see what date next Tuesday is, or that I can have an IRC chat without leaving my editor, or that I can organise my life. I like the fact that there is Lisp behind it all and I can tweak around with it if I want or that I&#8217;m getting pretty efficient with Emacs for my day-to-day work. And I love the fact that I&#8217;m not a newbie any more, but I still have loads to learn.</p>
<p>Finally, with the above two aspects in mind, I have been using Emacs in console mode exclusively since my epiphany of &#8220;stick with Emacs&#8221;. This way I can get a better representation if I decide to set up a VPS so I can work remotely. And you know what. It&#8217;s absolutely fine! Normally I use Emacs (GTK I think, not XEmacs) which is great, but in console I can&#8217;t use the mouse, and this is brilliant! (I hate rodents). It doesn&#8217;t play so nicely with Tmux, but I&#8217;m using the shell witin Emacs much more, and for what I need, it&#8217;s fine.</p>
<p>So, there you have it. Sorry Vim, I hardly knew ya. Hello Emacs, I&#8217;m back!</p>
<img src="http://www.robsearles.com/?ak_action=api_record_view&id=645&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/RobSearles?a=QJpbdG78Wmo:tanxleyo_Cc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/RobSearles?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/RobSearles/~4/QJpbdG78Wmo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.robsearles.com/2012/03/28/not-switching-from-emacs-to-vim/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.robsearles.com/2012/03/28/not-switching-from-emacs-to-vim/</feedburner:origLink></item>
		<item>
		<title>Switching from Emacs to Vim?</title>
		<link>http://feedproxy.google.com/~r/RobSearles/~3/5OQ1q6OL8r4/</link>
		<comments>http://www.robsearles.com/2012/03/20/switching-from-emacs-to-vim/#comments</comments>
		<pubDate>Tue, 20 Mar 2012 13:25:42 +0000</pubDate>
		<dc:creator>Rob Searles</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Emacs]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://www.robsearles.com/?p=643</guid>
		<description><![CDATA[As my regular reader will know, I&#8217;m a heavy Emacs user (have been now for over two years). So why this heretical thinking then? A number of reasons. Firstly, I find I&#8217;m spending more and more time editing directly on a server. Obviously Emacs can handle this with Tramp mode. Yes, that&#8217;s true, but it would be much [...]]]></description>
			<content:encoded><![CDATA[<p>As my regular reader will know, I&#8217;m a heavy Emacs user (have been now for <a href="http://www.robsearles.com/2009/10/25/a-week-with-emacs-one-week-later/">over two years</a>). So why this heretical thinking then?</p>
<p>A number of reasons.</p>
<p>Firstly, I find I&#8217;m spending more and more time editing directly on a server. Obviously Emacs can handle this with Tramp mode.</p>
<p>Yes, that&#8217;s true, but it would be much nicer just to have the editor there on the same system. I could install Emacs on the server, but for some reason I can never get Meta keys mapping correctly, or Meta-Ctrl working when using emails within a terminal.</p>
<p>Secondly, as I spend all day logged into servers via SSH, I&#8217;m increasingly spending more of my time in Tmux. A result of this is that I&#8217;m starting to get confused with the binding keys when in Emacs and when in Tmux. This is not great.</p>
<p>Thirdly and this is more due to Tmux&#8217;s credit than Emac&#8217;s failure, I love Tmux&#8217;s sessions. I currently have a central server that I connect to. On that server I have a number of Tmux sessions running. I simply love being able to open up my &#8220;live&#8221; session and carry on where I left off. This is especially useful for me as I have three workstations &#8211; home, work and laptop. The downside of this is that when I don&#8217;t have internet access, I can&#8217;t get to my sessions.</p>
<p>Finally. Because I want to learn Vim. I may not move over to it full time if at all. But it would be good to know what &#8220;the other side&#8221; was really like. It may be crap. I don&#8217;t know.</p>
<p>But I want to find out.</p>
<img src="http://www.robsearles.com/?ak_action=api_record_view&id=643&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/RobSearles?a=5OQ1q6OL8r4:COz4W720Nps:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/RobSearles?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/RobSearles/~4/5OQ1q6OL8r4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.robsearles.com/2012/03/20/switching-from-emacs-to-vim/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.robsearles.com/2012/03/20/switching-from-emacs-to-vim/</feedburner:origLink></item>
		<item>
		<title>Great video showing off Tmux</title>
		<link>http://feedproxy.google.com/~r/RobSearles/~3/pUbMSaxY4B4/</link>
		<comments>http://www.robsearles.com/2012/03/14/great-video-showing-off-tmux/#comments</comments>
		<pubDate>Wed, 14 Mar 2012 13:20:11 +0000</pubDate>
		<dc:creator>Rob Searles</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[tmux]]></category>

		<guid isPermaLink="false">http://www.robsearles.com/?p=639</guid>
		<description><![CDATA[I&#8217;m a heavy user of Tmux (spending roughly 45% of my time in it these days). But if you don&#8217;t know Tmux then Brian Hogan has a great video showing what it can do. http://www.youtube.com/watch?v=JXwS7z6Dqic If you liked the video, you may want to buy his book. Some other great Tmux resources include: Hawkhost Tmux [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m a heavy user of <a href="http://tmux.sourceforge.net/" target="_blank">Tmux</a> (spending roughly 45% of my time in it these days). But if you don&#8217;t know Tmux then Brian Hogan has a great video showing what it can do.</p>
<p><a href="http://www.youtube.com/watch?v=JXwS7z6Dqic">http://www.youtube.com/watch?v=JXwS7z6Dqic</a></p>
<p>If you liked the video, you may want to <a href="http://pragprog.com/book/bhtmux/tmux" target="_blank">buy his book</a>.</p>
<p>Some other great Tmux resources include:</p>
<ul>
<li>Hawkhost Tmux tutorial, parts <a href="http://blog.hawkhost.com/2010/06/28/tmux-the-terminal-multiplexer/" target="_blank">one</a> and <a href="http://blog.hawkhost.com/2010/07/02/tmux-%E2%80%93-the-terminal-multiplexer-part-2/" target="_blank">two</a></li>
<li><a href="https://wiki.archlinux.org/index.php/Tmux" target="_blank">Arch Linux wiki page</a></li>
<li><a href="http://mutelight.org/articles/practical-tmux" target="_blank">Blog post by Brandur</a></li>
</ul>
<img src="http://www.robsearles.com/?ak_action=api_record_view&id=639&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/RobSearles?a=pUbMSaxY4B4:3myFzShQ5Kk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/RobSearles?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/RobSearles/~4/pUbMSaxY4B4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.robsearles.com/2012/03/14/great-video-showing-off-tmux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.robsearles.com/2012/03/14/great-video-showing-off-tmux/</feedburner:origLink></item>
		<item>
		<title>Looking for an UltraBook</title>
		<link>http://feedproxy.google.com/~r/RobSearles/~3/g9UtyFafl9Y/</link>
		<comments>http://www.robsearles.com/2012/03/12/looking-for-an-ultrabook/#comments</comments>
		<pubDate>Mon, 12 Mar 2012 12:18:19 +0000</pubDate>
		<dc:creator>Rob Searles</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[hardware]]></category>
		<category><![CDATA[laptop]]></category>

		<guid isPermaLink="false">http://www.robsearles.com/?p=613</guid>
		<description><![CDATA[It looks like I&#8217;m going to be doing a lot of travelling in the near future. This is all well and good, but my current laptop (a Sony Vaio VGN-Z) is starting to creak, and has quite a low battery life. This is unfortunate, as I really like my Vaio; the screen resolution is good, the [...]]]></description>
			<content:encoded><![CDATA[<p>It looks like I&#8217;m going to be doing a lot of travelling in the near future. This is all well and good, but my current laptop (a Sony Vaio VGN-Z) is starting to creak, and has quite a low battery life. This is unfortunate, as I really like my Vaio; the screen resolution is good, the weight is fantastic (roughly 1.6kg), and the keyboard is a pleasure to type/code with.</p>
<p>So I have a couple of options. I could hack about with my Vaio and try to increase performance and battery life. Or, I could buy a new laptop.</p>
<p>For the first option it looks like the <a href="http://www.extremetech.com/computing/112097-linux-3-2-kernel-released-what-you-need-to-know" target="_blank">3.2 kernel will offer battery life improvements</a>, so I could have a go at upgrading to this. I could try installing a different flavour of Linux, one designed for increased battery life, such as <a href="http://www.fuduntu.org/" target="_blank">Fundutu</a> or even <a href="http://www.archlinux.org/">Arch</a>, and heavily tweak it, but I had a nightmare last time I tried Arch on the Vaio.</p>
<p>If none of these work then I&#8217;ll have to look into getting a new laptop. I have some strict criteria for choosing the laptop:</p>
<ul>
<li>Must weigh the same or less than my Vaio (1.6kg)</li>
<li>Must have a long battery life (6 hours+)</li>
<li>Must be able to run Linux (Ubuntu or Arch) with minimal tweaking</li>
</ul>
<p>I&#8217;ve been doing some research and the best two seem to be the <a href="http://store.apple.com/uk/browse/home/shop_mac/family/macbook_air">MacBook Air 13 inch</a> and the <a href="http://www.dell.com/uk/business/p/latitude-e6220/pd" target="_blank">Dell Latitude E6220</a></p>
<p><strong>1. Dell Latitude E6220</strong></p>
<p>This comes in at the same weight as my Vaio but less screen resolution.  However, it is <a href="http://www.ubuntu.com/certification/hardware/201102-7188" target="_blank">Ubuntu Certified</a> (whatever that means—I assume it&#8217;s good) and the best thing is the battery life is roughly 7.5 hours.  Price is roughly £1,000 including UK VAT.</p>
<p><strong>2. MacBook Air</strong></p>
<p>The weight of this thing is just silly, and with a 7 hour battery life you can&#8217;t complain. However, it&#8217;s a Mac! I know I&#8217;m going against the grain, and my father would disown me if he ever saw this sentence, but I don&#8217;t really like Macs. Don&#8217;t get me wrong: they look great, and they are far superior to Windows, but there are some irritating features about them that completely throw me. However, upon some research it appears <a href="https://help.ubuntu.com/community/MacBookAir4-2#LCD" target="_blank">Ubuntu is installable after some tweaking</a>.</p>
<p>I went through the config screens for both the Apple and the Dell to see if I could get the specs as close as possible to compare the price, initially assuming that the Mac would be far more expensive. It turns out that they are pretty much neck-and-neck.</p>
<div id="attachment_615" class="wp-caption alignright" style="width: 310px"><img class="size-medium wp-image-615" title="For Fuck Sake Dell 2012" src="http://www.robsearles.com/wp-content/uploads/2012/02/2012-02-02-160928_738x240_scrot-300x97.png" alt="£1.00 per month for 36 months to install an outdated version of FireFox." width="300" height="97" /><p class="wp-caption-text">£1.00 per month for 36 months to install an outdated version of FireFox.</p></div>
<p>However, whilst selecting the software to install on the Dell, as well as the mandatory shitload of bloatware which couldn&#8217;t be &#8220;Not Included&#8221; there was the option to install <strong>Firefox 3.06 at a cost of £7.00</strong>! For fuck&#8217;s sake, Dell! Charging <strong>seven pounds</strong> to install an <strong>out-of-date browser?</strong>! Actually, it gets worse. You can also opt to pay by installment: just £1.00 per month over a period of 36 months!</p>
<p><strong>Dell, I&#8217;ve scratched you off my shortlist.</strong></p>
<p>So, it looks like I have more research to do, some of which includes:</p>
<ul>
<li>Asus Zenbook UX21E</li>
<li>Lenovo IdeaPad U300s</li>
<li>Asus Zenbook UX21E review</li>
</ul>
<p>The search continues.</p>
<img src="http://www.robsearles.com/?ak_action=api_record_view&id=613&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/RobSearles?a=g9UtyFafl9Y:szIzkD_UONc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/RobSearles?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/RobSearles/~4/g9UtyFafl9Y" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.robsearles.com/2012/03/12/looking-for-an-ultrabook/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.robsearles.com/2012/03/12/looking-for-an-ultrabook/</feedburner:origLink></item>
		<item>
		<title>I’ve Turned into a Hipster</title>
		<link>http://feedproxy.google.com/~r/RobSearles/~3/-DoNBQjRfq0/</link>
		<comments>http://www.robsearles.com/2012/02/02/ive-turned-into-a-hipster/#comments</comments>
		<pubDate>Thu, 02 Feb 2012 15:36:21 +0000</pubDate>
		<dc:creator>Rob Searles</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[coffeescript]]></category>
		<category><![CDATA[hipster]]></category>
		<category><![CDATA[nodejs]]></category>

		<guid isPermaLink="false">http://www.robsearles.com/?p=602</guid>
		<description><![CDATA[After playing around with CoffeeScript, I find it is too good not to use. So now I am a CoffeeScript coder. Does this mean I'm a hipster? How embarrassing.]]></description>
			<content:encoded><![CDATA[<p style="text-align: center; line-height: 14.25pt; background: white;" align="center"><img class="aligncenter size-full wp-image-624" style="font-family: Georgia; font-size: 10pt; background-color: white; line-height: 14.25pt;" title="Hipster Dog" src="http://www.robsearles.com/wp-content/uploads/2012/01/Hipster-Dog-Is-Here.jpg" alt="Hipster Dog" width="600" height="300" /></p>
<p style="line-height: 14.25pt; background: white;"><span style="font-size: 10.0pt; font-family: Georgia;" lang="EN-CA">I’ve seen a day I never thought would come:  the day I turned into a hipster!</span></p>
<p style="line-height: 14.25pt; background: white;"><span style="font-size: 10.0pt; font-family: Georgia;" lang="EN-CA">If you&#8217;ve been following this blog, you&#8217;ll have noticed that throughout 2011 I&#8217;ve been working<span> </span></span><span lang="EN-CA"><a title="Node.JS: Experiments with Processes" href="http://www.robsearles.com/2011/09/28/nodejs-experiments-with-processes/"><span style="font-size: 10.0pt; font-family: Georgia;">more</span></a></span><span><span style="font-size: 10.0pt; font-family: Georgia;" lang="EN-CA"> </span></span><span style="font-size: 10.0pt; font-family: Georgia;" lang="EN-CA">and<span> </span></span><span lang="EN-CA"><a title="Node.JS: Experiments with the Middle End, Part 1" href="http://www.robsearles.com/2011/10/20/nodejs-experiments-with-middle-end-part1/"><span style="font-size: 10.0pt; font-family: Georgia;">more</span></a></span><span><span style="font-size: 10.0pt; font-family: Georgia;" lang="EN-CA"> </span></span><span style="font-size: 10.0pt; font-family: Georgia;" lang="EN-CA">in Javascript, more specifically with<span> </span></span><span lang="EN-CA"><a href="http://nodejs.org/" target="_blank"><span style="font-size: 10.0pt; font-family: Georgia;">Node.JS</span></a></span><span style="font-size: 10.0pt; font-family: Georgia;" lang="EN-CA">.</span></p>
<p style="line-height: 14.25pt; background: white;"><span style="font-size: 10.0pt; font-family: Georgia;" lang="EN-CA">The last few months have been especially Node.JS-centric. During the day, I&#8217;ve been building architectural improvements into<span> </span><a href="http://www.jabbakam.com/" target="_blank">Jabbakam</a>. Evenings and weekends, I’ve been  hacking about on the<span> </span></span><span lang="EN-CA"><a href="http://www.liveunsigned.com/" target="_blank"><span style="font-size: 10.0pt; font-family: Georgia;">Live Unsigned</span></a></span><span><span style="font-size: 10.0pt; font-family: Georgia;" lang="EN-CA"> </span></span><span style="font-size: 10.0pt; font-family: Georgia;" lang="EN-CA">mobile site. All of my recent projects revolve around Node.JS, and I&#8217;ve been loving it. Node is incredibly interesting and powerful, and it is giving my brain a workout.</span></p>
<p style="line-height: 14.25pt; background: white;"><span style="font-size: 10.0pt; font-family: Georgia;" lang="EN-CA">However, Javascript itself has a few niggly bits that become more problematic the larger the project gets. Issues with structure and maintainability of code motivate projects such as<span> </span><a href="http://joose.it/" target="_blank">Joose</a><span> </span>and </span><span lang="EN-CA"><a href="http://documentcloud.github.com/backbone/" target="_blank"><span style="font-size: 10.0pt; font-family: Georgia;">Backbone.js</span></a></span><span style="font-size: 10.0pt; font-family: Georgia;" lang="EN-CA">. One of the things that has been bugging me is having to hack in class-based inheritance. After a lot of experimentation, I settled on<span> </span></span><span lang="EN-CA"><a href="http://javascript.crockford.com/prototypal.html" target="_blank"><span style="font-size: 10.0pt; font-family: Georgia;">Prototypal Inheritance</span></a></span><span style="font-size: 10.0pt; font-family: Georgia;" lang="EN-CA">, which does the job to an extent, but left me dissatisfied .<a name="_GoBack"></a></span></p>
<p style="line-height: 14.25pt; background: white;"><span style="font-size: 10.0pt; font-family: Georgia;" lang="EN-CA">So, the other day I finally broke down and tried<span> </span><a href="http://coffeescript.org/" target="_blank">CoffeeScript</a>.</span></p>
<p style="line-height: 14.25pt; background: white;"><span style="font-size: 10.0pt; font-family: Georgia;" lang="EN-CA">When CoffeeScript first came out I resolved never to bother with it. It is clearly for<span> </span></span><span lang="EN-CA"><a href="http://www.youtube.com/watch?v=cAy4zULKFDU" target="_blank"><span style="font-size: 10.0pt; font-family: Georgia;">Ruby people</span></a></span><span><span style="font-size: 10.0pt; font-family: Georgia;" lang="EN-CA"> </span></span><span style="font-size: 10.0pt; font-family: Georgia;" lang="EN-CA">who don&#8217;t quite understand Javascript. Since then it&#8217;s been getting a<span> </span></span><span lang="EN-CA"><a href="http://net.tutsplus.com/tutorials/javascript-ajax/rocking-out-with-coffeescript/" target="_blank"><span style="font-size: 10.0pt; font-family: Georgia;">lot</span></a></span><span><span style="font-size: 10.0pt; font-family: Georgia;" lang="EN-CA"> </span></span><span lang="EN-CA"><a href="http://amix.dk/blog/post/19612" target="_blank"><span style="font-size: 10.0pt; font-family: Georgia;">of</span></a></span><span><span style="font-size: 10.0pt; font-family: Georgia;" lang="EN-CA"> </span></span><span lang="EN-CA"><a href="http://dailyjs.com/2011/05/30/code-review-coffeescript/" target="_blank"><span style="font-size: 10.0pt; font-family: Georgia;">press</span></a></span><span style="font-size: 10.0pt; font-family: Georgia;" lang="EN-CA">, and it now even has<span> </span><a href="http://pragprog.com/book/tbcoffee/coffeescript" target="_blank">its own book</a>!</span></p>
<p style="line-height: 14.25pt; background: white;"><span style="font-size: 10.0pt; font-family: Georgia;" lang="EN-CA">Anyway, I was up the other night, waiting for my daughter to wake up in screaming pain as razor-sharp pieces of enamel slowly bored through her gums. With nothing better to do, I decided to play around with CoffeeScript.</span></p>
<p style="line-height: 14.25pt; background: white;"><span style="font-size: 10.0pt; font-family: Georgia;" lang="EN-CA">I was up and running in no time, installing the<span> </span></span><span lang="EN-CA"><a href="http://search.npmjs.org/#/coffee-script" target="_blank"><span style="font-size: 10.0pt; font-family: Georgia;">Node.JS Module</span></a></span><span><span style="font-size: 10.0pt; font-family: Georgia;" lang="EN-CA"> </span></span><span style="font-size: 10.0pt; font-family: Georgia;" lang="EN-CA">and browsing the<span> </span></span><span lang="EN-CA"><a href="http://arcturo.github.com/library/coffeescript/" target="_blank"><span style="font-size: 10.0pt; font-family: Georgia;">Little Book of CoffeeScript</span></a></span><span style="font-size: 10.0pt; font-family: Georgia;" lang="EN-CA">. After about an hour I had effortlessly written some additions to Live Unsigned which integrated seamlessly. To be honest, I feel like a bit of a muppet for not trying it sooner.</span></p>
<p style="line-height: 14.25pt; background: white;"><span style="font-size: 10.0pt; font-family: Georgia;" lang="EN-CA">After just a couple of days playing around with it, CoffeeScript has now become a major part of my toolkit. The syntax is elegant, nicely lending itself to clean coding, and code can be reused easily, improving project structure. CoffeeScript compiles to pretty clean Javascript, and from what I can make out, the better you understand Javascript, the better CoffeeScript you can write.</span></p>
<p style="line-height: 14.25pt; background: white;"><span style="font-size: 10.0pt; font-family: Georgia;" lang="EN-CA">So yes, I am now coding in CoffeeScript.</span></p>
<p style="line-height: 14.25pt; background: white;"><span style="font-size: 10.0pt; font-family: Georgia;" lang="EN-CA">I am now a hipster.</span></p>
<p style="line-height: 14.25pt; background: white;"><span style="font-size: 10.0pt; font-family: Georgia;" lang="EN-CA">There is nothing left for me but to rush out, buy some skinny jeans and a Macbook Air and learn Vim.</span></p>
<p style="line-height: 14.25pt; background: white;"><span style="font-size: 10.0pt; font-family: Georgia;" lang="EN-CA">Oh, God.</span></p>
<img src="http://www.robsearles.com/?ak_action=api_record_view&id=602&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/RobSearles?a=-DoNBQjRfq0:lLOMiy8JrOE:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/RobSearles?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/RobSearles/~4/-DoNBQjRfq0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.robsearles.com/2012/02/02/ive-turned-into-a-hipster/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://www.robsearles.com/2012/02/02/ive-turned-into-a-hipster/</feedburner:origLink></item>
		<item>
		<title>NodeJS: Experiments with Middle End Part 3</title>
		<link>http://feedproxy.google.com/~r/RobSearles/~3/q07RLDbFcIE/</link>
		<comments>http://www.robsearles.com/2011/12/07/nodejs-experiments-with-middle-end-part-3/#comments</comments>
		<pubDate>Wed, 07 Dec 2011 12:53:47 +0000</pubDate>
		<dc:creator>Rob Searles</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[experiments]]></category>
		<category><![CDATA[nodejs]]></category>

		<guid isPermaLink="false">http://www.robsearles.com/?p=529</guid>
		<description><![CDATA[Note: This is the last in a series of posts describing my experiments with constructing a Middle End. In Part 1, we discussed the concept of the middle end and its advantages. In Part 2, we constructed a very simple example. In this post, we&#8217;re going to make that example slightly more complex by introducing [...]]]></description>
			<content:encoded><![CDATA[<div style="background: #FFFEEB; margin: 10px 0 0 0; padding: 5px 10px; border: 1px solid #ccc;"><strong>Note: </strong> This is the last in a series of posts describing my experiments with constructing a Middle End. In <a href="http://www.robsearles.com/2011/10/20/nodejs-experiments-with-middle-end-part1/">Part 1</a>, we discussed the concept of the middle end and its advantages. In <a href="http://www.robsearles.com/2011/12/02/nodejs-experiments-with-middle-end-part-2">Part 2</a>, we constructed a very simple example.</div>
<p>In this post, we&#8217;re going to make that example slightly more complex by introducing dependencies within the modules. Now the code must be able to handle these dependencies for both the client side and the server side.</p>
<p>In the<a href="http://www.robsearles.com/2011/12/02/nodejs-experiments-with-middle-end-part-2"> last post</a>, we built a simple module consisting of a single function that returned a greeting:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> Greetings <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> <span style="color: #009900;">&#125;</span>
Greetings.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">hello</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>who<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">&quot;Hello &quot;</span><span style="color: #339933;">+</span>who;
<span style="color: #009900;">&#125;</span>
module.<span style="color: #660066;">exports</span> <span style="color: #339933;">=</span> Greetings;</pre></div></div>

<p>At this point, it would be very useful to sanitize and validate the parameter passed to the &#8220;hello&#8221; function. We could obviously build this functionality directly into the code, but this is exactly the sort of thing that should be abstracted into its own module(s).</p>
<p>For the purpose of this example, we&#8217;ll simply include the functionality to give the parameter passed a &#8220;trim&#8221;; after some hacking and snippet-borrowing from <a href="https://github.com/chriso/node-validator" target="_blank">node-validator</a> by Chris O&#8217;Hara, we can build another simple module called Tidy:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> Tidy <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
   whitespace<span style="color: #339933;">:</span> <span style="color: #3366CC;">'<span style="color: #000099; font-weight: bold;">\\</span>r<span style="color: #000099; font-weight: bold;">\\</span>n<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>s'</span><span style="color: #339933;">,</span>
&nbsp;
   trim<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>str<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #003366; font-weight: bold;">var</span> whitespace <span style="color: #339933;">=</span>  <span style="color: #3366CC;">'<span style="color: #000099; font-weight: bold;">\\</span>r<span style="color: #000099; font-weight: bold;">\\</span>n<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>s'</span>;
      str <span style="color: #339933;">=</span> str.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> RegExp<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'^['</span><span style="color: #339933;">+</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">whitespace</span><span style="color: #339933;">+</span><span style="color: #3366CC;">']+|['</span><span style="color: #339933;">+</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">whitespace</span><span style="color: #339933;">+</span><span style="color: #3366CC;">']+$'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'g'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span>
      <span style="color: #000066; font-weight: bold;">return</span> str;
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
module.<span style="color: #660066;">exports</span> <span style="color: #339933;">=</span> Tidy;</pre></div></div>

<p>We can now improve our Greetings module, including the dependency and functionality:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> Tidy <span style="color: #339933;">=</span> require<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./tidy'</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> Greetings <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> <span style="color: #009900;">&#125;</span>
Greetings.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">hello</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>who<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   who <span style="color: #339933;">=</span> Tidy.<span style="color: #660066;">trim</span><span style="color: #009900;">&#40;</span>who<span style="color: #009900;">&#41;</span>;
   <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">hello</span><span style="color: #009900;">&#40;</span>who<span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span>
module.<span style="color: #660066;">exports</span> <span style="color: #339933;">=</span> Greetings;</pre></div></div>

<p>To see if this will work as expected, let&#8217;s add some spaces to the parameter passed in the NodeJS script:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> Greetings <span style="color: #339933;">=</span> require<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./greetings'</span><span style="color: #009900;">&#41;</span>;
<span style="color: #003366; font-weight: bold;">var</span> greetings <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Greetings<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>greetings.<span style="color: #660066;">hello</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'  Node   '</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;!&quot;</span><span style="color: #009900;">&#41;</span>;</pre></div></div>

<p>When we run it, this is what we see:</p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;">$ node runner.js
Hello Node<span style="color: #000000; font-weight: bold;">!</span></pre></div></div>

<p>Good, so this works on the server side, but let’s test its behaviour on the client side. Again, we should add some spaces to the parameter passed to ensure that it is working:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;script type=&quot;text/javascript&quot;&gt; &lt;/script&gt;
&lt;script src=&quot;greetings.js&quot; type=&quot;text/javascript&quot;&gt; &lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt; &lt;/script&gt;</pre></div></div>

<p>Unfortunately, we now see the following error:</p>

<div class="wp_syntax"><div class="code"><pre class="text text" style="font-family:monospace;">require is not defined
[Break On This Error] var greetings = new Greetings();</pre></div></div>

<p>Our attempt to &#8220;require&#8221; the dependency in the Greetings module has broken the client side. To fix this, we need to define our own <strong>require()</strong> function, much like we had to for the <strong>module</strong> object. We do this by creating a new front end-only script, which we&#8217;ll call &#8220;middle-end.js&#8221;.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> require <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>module<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   document.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;script src=&quot;'</span><span style="color: #339933;">+</span>module<span style="color: #339933;">+</span><span style="color: #3366CC;">'.js&quot; type=&quot;text/javascript&quot;&gt; &lt;/script&gt;'</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> module <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
   exports<span style="color: #339933;">:</span> undefined
<span style="color: #009900;">&#125;</span>;</pre></div></div>

<p><em>(Obviously we should include much more error checking, but this will be enough for our example).</em></p>
<p>We modify our html as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;script src=&quot;middle-end.js&quot; type=&quot;text/javascript&quot;&gt; &lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt; &lt;/script&gt;
....</pre></div></div>

<p>Now when we reload the page in the browser, all should work as expected. Huzzah!</p>
<p>This is just a very simple example of what can be done when JavaScript code is shared between the client and server sides—the &#8220;Middle End&#8221;. This concept becomes really exciting when you start thinking about potential approaches to form validation, session management, and even display logic. This is definitely something worth playing around with.</p>
<p><a href="https://gist.github.com/1254879" target="_blank">All of the code is available as a Gist</a>.</p>
<img src="http://www.robsearles.com/?ak_action=api_record_view&id=529&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/RobSearles?a=q07RLDbFcIE:ac_zo19kny4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/RobSearles?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/RobSearles/~4/q07RLDbFcIE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.robsearles.com/2011/12/07/nodejs-experiments-with-middle-end-part-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.robsearles.com/2011/12/07/nodejs-experiments-with-middle-end-part-3/</feedburner:origLink></item>
		<item>
		<title>NodeJS: Experiments with Middle End Part 2</title>
		<link>http://feedproxy.google.com/~r/RobSearles/~3/xT07LaiHZmU/</link>
		<comments>http://www.robsearles.com/2011/12/02/nodejs-experiments-with-middle-end-part-2/#comments</comments>
		<pubDate>Fri, 02 Dec 2011 13:48:37 +0000</pubDate>
		<dc:creator>Rob Searles</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[experiments]]></category>
		<category><![CDATA[nodejs]]></category>

		<guid isPermaLink="false">http://www.robsearles.com/?p=519</guid>
		<description><![CDATA[Note: This is the second in a series of posts describing my experiments with constructing a Middle End. In Part 1, we discussed the concept of the middle end and its advantages. In my previous post, I talked about Kyle Simpson&#8217;s concept of a Middle End—a layer between the front end and back end. Today, [...]]]></description>
			<content:encoded><![CDATA[<div style="background: #FFFEEB; margin: 10px 0 0 0; padding: 5px 10px; border: 1px solid #ccc;"><strong>Note: </strong> This is the second in a series of posts describing my experiments with constructing a Middle End. In <a href="http://www.robsearles.com/2011/10/20/nodejs-experiments-with-middle-end-part1/">Part 1</a>, we discussed the concept of the middle end and its advantages.</div>
<p>In my previous post, I talked about <a href="http://blog.getify.com/" target="_blank">Kyle Simpson&#8217;s</a> concept of a Middle End—a layer between the front end and back end. Today, I&#8217;m going to sketch out my very simple experiments with constructing such a layer.</p>
<p>What I am focusing on here is simply a means of sharing JavaScript code between the client side and the server side.</p>
<p>Let&#8217;s start with a very simple NodeJS Module, <em>greetings.js</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> Greetings <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> <span style="color: #009900;">&#125;</span>
Greetings.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">hello</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>who<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">&quot;Hello &quot;</span><span style="color: #339933;">+</span>who;
<span style="color: #009900;">&#125;</span>
module.<span style="color: #660066;">exports</span> <span style="color: #339933;">=</span> Greetings;</pre></div></div>

<p>Next, let&#8217;s create a very simple NodeJS script that imports this module, and uses it:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> Greetings <span style="color: #339933;">=</span> require<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./greetings'</span><span style="color: #009900;">&#41;</span>;
<span style="color: #003366; font-weight: bold;">var</span> greetings <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Greetings<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>greetings.<span style="color: #660066;">hello</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Node'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;!&quot;</span><span style="color: #009900;">&#41;</span>;</pre></div></div>

<p>When we run it, this is what we get:</p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;">$ node test.js
Hello Node<span style="color: #000000; font-weight: bold;">!</span></pre></div></div>

<p>All very simple stuff.</p>
<p>Now, suppose we want to use the Greetings module in our front end web app. </p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;script src=&quot;greetings.js&quot; type=&quot;text/javascript&quot;&gt; &lt;/script&gt;</pre></div></div>

<p>Well, it runs and we get the desired output. However, Firebug reports an error within the greetings.js file:</p>

<div class="wp_syntax"><div class="code"><pre class="text text" style="font-family:monospace;">module is not defined
[Break On This Error] module.exports = Greetings;</pre></div></div>

<p>The solution to this issue is to &#8220;mock up&#8221; the module object so the error isn&#8217;t thrown:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> module <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
   exports<span style="color: #339933;">:</span> undefined
<span style="color: #009900;">&#125;</span>;</pre></div></div>

<p>Run it again, and now we see no errors.</p>
<p>Great, so it&#8217;s working. We can share simple modules between the client and the server sides.</p>
<p>But what if we want to have a more complex module? One that has some dependencies?</p>
<p>That will be discussed in the next post.</p>
<p><a href="https://gist.github.com/1254879" target="_blank">All of the code is available as a Gist</a>.</p>
<img src="http://www.robsearles.com/?ak_action=api_record_view&id=519&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/RobSearles?a=xT07LaiHZmU:9iYWzHiQma0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/RobSearles?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/RobSearles/~4/xT07LaiHZmU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.robsearles.com/2011/12/02/nodejs-experiments-with-middle-end-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.robsearles.com/2011/12/02/nodejs-experiments-with-middle-end-part-2/</feedburner:origLink></item>
		<item>
		<title>Arch Linux Virtualbox Update</title>
		<link>http://feedproxy.google.com/~r/RobSearles/~3/e5gWB9UqfMI/</link>
		<comments>http://www.robsearles.com/2011/11/29/arch-linux-virtualbox-update/#comments</comments>
		<pubDate>Tue, 29 Nov 2011 14:07:08 +0000</pubDate>
		<dc:creator>Rob Searles</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[arch]]></category>

		<guid isPermaLink="false">http://www.robsearles.com/?p=306</guid>
		<description><![CDATA[Gosh! I just found this in my list of draft posts (originally written in early 2010). I thought I might as well post it as it could be useful to someone out there? Again, this is one of those posts more for me, but hopefully other people might find it useful. Recently I updated my [...]]]></description>
			<content:encoded><![CDATA[<div style="background: #E0ECF8; margin: 10px 0 0 0; padding: 5px 10px; border: 1px solid #ccc;">
Gosh! I just found this in my list of draft posts (originally written in early 2010). I thought I might as well post it as it could be useful to someone out there?</div>
<p>Again, this is one of those posts more for me, but hopefully other people might find it useful.</p>
<p>Recently I updated my Arch Linux box</p>
<p># pacman -Syu</p>
<p>and during this update a new kernel was added &#8211; which meant that my VirtualBox installation didn&#8217;t work any more, chucking out the following message</p>
<p>The VirtualBox Linux kernel driver (vboxdrv) is either not loaded or there is a permission problem with /dev/vboxdrv. Re-setup the kernel module by executing</p>
<p>&#8216;/etc/init.d/vboxdrv setup&#8217;</p>
<img src="http://www.robsearles.com/?ak_action=api_record_view&id=306&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/RobSearles?a=e5gWB9UqfMI:09UkluVG6_g:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/RobSearles?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/RobSearles/~4/e5gWB9UqfMI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.robsearles.com/2011/11/29/arch-linux-virtualbox-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.robsearles.com/2011/11/29/arch-linux-virtualbox-update/</feedburner:origLink></item>
		<item>
		<title>NodeJS: Experiments with Middle End Part 1</title>
		<link>http://feedproxy.google.com/~r/RobSearles/~3/RG98rLUgg6E/</link>
		<comments>http://www.robsearles.com/2011/10/20/nodejs-experiments-with-middle-end-part1/#comments</comments>
		<pubDate>Thu, 20 Oct 2011 21:33:39 +0000</pubDate>
		<dc:creator>Rob Searles</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[experiments]]></category>
		<category><![CDATA[middle-end]]></category>
		<category><![CDATA[nodejs]]></category>

		<guid isPermaLink="false">http://www.robsearles.com/?p=515</guid>
		<description><![CDATA[Back in October last year (2010) a bunch of us fled Berlin and made for Warsaw. Not just for the Vodka you understand, but more specifically for the Front-Trends conference. One of the talks was discussing the concept of the Middle End, by Kyle Simpson. This really made an impression on me, and I think [...]]]></description>
			<content:encoded><![CDATA[<p>Back in October last year (2010) a bunch of us fled Berlin and made for Warsaw. Not just for the Vodka you understand, but more specifically for the Front-Trends conference.</p>
<p>One of the talks was discussing the concept of the <a href="http://blog.getify.com/2010/07/what-exactly-is-the-middle-end/" target="_blank">Middle End, by Kyle Simpson</a>. This really made an impression on me, and I think I probably bored Kyle in the bar afterwards with my drunken enthusing. When we arrived back home, my aim was to start playing around with the idea of a Middle End as soon as possible. Unfortunately, as is life, events took over (such as discovering one is going to become a dad!) and these thoughts were consigned to the back of my mind.</p>
<p>Until now</p>
<p><span id="more-515"></span></p>
<p>The more I hack around with NodeJS the more I&#8217;ve been able to experiment with different aspects of it. Well, today I began hacking around with some Middle End concepts.</p>
<p>The idea of the Middle End is quite simple.</p>
<p>In a web application there is traditionally the Front End and the Back End. The front end handles all of the client side processing (such as rendering some whizzy JQuery plugins or whatever). The back end handles the actual hard crunching, such as retrieving and adding data from the storage engine.</p>
<p>However, there are certain aspects that both the front end <strong>and</strong> the back end need to handle. Some things that spring to mind are: session managment, input validation and possibly some display logic (Kyle&#8217;s post goes into some more depth here).</p>
<p>Currently these aspects are handled both by the front end and back end code, but as traditionally front end code is JavaScript where as back end code maybe Ruby, PHP, Python, etc that means there ends up being duplication of code. Two different languages doing the same thing.</p>
<p>This is in direct violation of the DRY principal. Quite simply, this is a waste.</p>
<p>There is a solution to this waste. Using JavaScript on the server side, effectively code can now be reused. But how can you use the same piece of code for the client side as well as the server side? In my next post I&#8217;ll be looking at how to do that.</p>
<img src="http://www.robsearles.com/?ak_action=api_record_view&id=515&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/RobSearles?a=RG98rLUgg6E:YUmepmgMXmM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/RobSearles?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/RobSearles/~4/RG98rLUgg6E" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.robsearles.com/2011/10/20/nodejs-experiments-with-middle-end-part1/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.robsearles.com/2011/10/20/nodejs-experiments-with-middle-end-part1/</feedburner:origLink></item>
	</channel>
</rss>

