<?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>OJ's rants &#187; Software Development</title>
	<atom:link href="http://buffered.io/category/software-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://buffered.io</link>
	<description>What would OJ do?</description>
	<lastBuildDate>Tue, 06 Jul 2010 20:32:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>BFPG June Meetup</title>
		<link>http://buffered.io/2010/06/25/bfpg-june-meetup/</link>
		<comments>http://buffered.io/2010/06/25/bfpg-june-meetup/#comments</comments>
		<pubDate>Fri, 25 Jun 2010 10:05:40 +0000</pubDate>
		<dc:creator>OJ</dc:creator>
				<category><![CDATA[Functional Programming]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[bfpg]]></category>
		<category><![CDATA[meetup]]></category>

		<guid isPermaLink="false">http://buffered.io/?p=835</guid>
		<description><![CDATA[The time has come for another meeting of the Functional Programming minds! This months BFPG Meetup, starting 6pm Monday 28th, is the first one at our new venue: Microsoft HQ, Waterfront Place, Brisbane. For details on the location, take a look at the BFPG about page. This month we have three speakers, and I am [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://buffered.io/wp-content/uploads/2010/06/Home.png" alt="Erlang Logo" style="float:right; margin-left:5px; margin-bottom: 5px;"/>The time has come for another meeting of the Functional Programming minds! This months <a href="http://www.meetup.com/Brisbane-Functional-Programming-Group-BFG/calendar/12636552/" title="June BFPG Meetup">BFPG Meetup</a>, starting 6pm Monday 28th, is the first one at our new venue: Microsoft HQ, Waterfront Place, Brisbane. For details on the location, take a look at the <a href="http://bfpg.org/about/" title="About BFPG">BFPG about page</a>.</p>
<p><img src="http://buffered.io/wp-content/uploads/2010/06/ruby.png" alt="Erlang Logo" style="float:left; margin-right:5px; margin-bottom: 5px;"/>This month we have three speakers, and I am one of them! In my talk, "Erlang - Why should you care?", I will be giving a fairly non-technical introduction to <a href="http://erlang.org/" title="Erlang">Erlang</a>. I'll be covering off the features of the language, some of its design goals and its history. I aiming to show that this language is not one that was spawned out of academia and that it has been applied in the real-world ever since its conception. If I have time, I'll also be giving a small demonstration of one of the neatest features of the technology.</p>
<p><img src="http://buffered.io/wp-content/uploads/2010/06/haskell-logo-variation.png" alt="Erlang Logo" style="float:right; margin-left:5px; margin-bottom: 5px;"/><br />
I'll be posting the slides and demonstration code here on this blog as well as <a href="http://bfpg.org/" title="BFPG">BFPG's home</a> after the meetup has taken place.</p>
<p>Myself and my comrades, <a href="http://adams.id.au/blog/" title="Nosewheelie">Tom</a> and <a href="http://blog.tmorris.net/" title="Tony's blog">Tony</a>, will aim to provide a fun and interesting evening at our new venue. Based on the RSVPs so far, it looks like we are going to have one of the biggest turn-outs to date. This is probably due to the exposure we got during last month's <a href="http://buffered.io/2010/05/22/dave-thomas-at-yow-nights-brisbane/" title="Dave Thomas at YOW! Nights Brisbane">talk by Dave Thomas</a>. There are still plenty of spots left, so if you're keen to come along, <a href="http://www.meetup.com/Brisbane-Functional-Programming-Group-BFG/calendar/12636552/" title="Sign up for BFPG June 10">go and sign up</a>. Bring your friends, your friend's friends and your mum.</p>
<p>I hope to see you there!</p>
<hr/>
<p><strong>Update (6th July 2010):</strong> We had a fantastic turn-out of just short of 50 people (a record breaker for the group so far!). My talk seemed to be fairly well-received. No rotten tomatoes were thrown and the crowd seemed engaged through most of the talk. It felt good! I think many people wanted to see more code, but since that wasn't the focus of the talk they were a little disappointed. If people are keen for more Erlang goodness at future meetups, then I'll be happy to dive a little deeper.</p>
<p>As promised, here are the slides:</p>
<ol>
<li><a href="https://docs.google.com/leaf?id=0B4v3XvOkiwsCZjNhZTk3OTYtZTgxNy00MjBmLWJiZmYtMzZjMzU3N2E3MDgz&#038;hl=en&#038;authkey=CIaRg_sF">PPTX</a></li>
<li><a href="https://docs.google.com/a/buffered.io/fileview?id=0B4v3XvOkiwsCMjlhMWRjNGItYmZkOC00ODRlLTkzYTUtOTI3ZWZhY2MxOGYx&#038;hl=en&#038;authkey=CM7rtpEO">PDF (Google Docs)</a></li>
<li><a href="https://docs.google.com/a/buffered.io/present/edit?id=0AYv3XvOkiwsCZGdmamd0eGNfN2dnaDh3emhw&#038;hl=en&#038;authkey=CJKBg-MB">PPT (Google Docs)</a></li>
</ol>
<p>If you have issues reading the slide deck, or would like it in another format, then please <a href="http://buffered.io/contact-me">drop me a line</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://buffered.io/2010/06/25/bfpg-june-meetup/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Dave Thomas at YOW! Nights Brisbane</title>
		<link>http://buffered.io/2010/05/22/dave-thomas-at-yow-nights-brisbane/</link>
		<comments>http://buffered.io/2010/05/22/dave-thomas-at-yow-nights-brisbane/#comments</comments>
		<pubDate>Sat, 22 May 2010 13:30:20 +0000</pubDate>
		<dc:creator>OJ</dc:creator>
				<category><![CDATA[Being in the Industry]]></category>
		<category><![CDATA[Functional Programming]]></category>
		<category><![CDATA[NoSQL]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://buffered.io/?p=830</guid>
		<description><![CDATA[Two nights ago I was fortunate enough to attend a YOW! Nights conference held at the local Microsoft Office here in Brisbane. The speaker for the session was none other than Dave Thomas, the man behind the likes of ObjectMentor. Not only is this guy incredibly switched on, he is thought-provoking and very entertaining to [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://buffered.io/wp-content/uploads/2010/05/haskell-logo-variation.png" alt="Haskell Logo" title="Haskell Logo" width="128" height="128" style="float:right;margin-left:5px;margin-bottom:5px" />Two nights ago I was fortunate enough to attend a <a href="http://yownightbrisbanemay.eventbrite.com/" title="YOW! Nights Brisbane - May 20th">YOW! Nights</a> conference held at the local Microsoft Office here in Brisbane. The speaker for the session was none other than <a href="http://www.davethomas.net/" title="Dave Thomas">Dave Thomas</a>, the man behind the likes of <a href="http://objectmentor.com/" title="Object Mentor">ObjectMentor</a>. Not only is this guy incredibly switched on, he is thought-provoking and very entertaining to boot. I've been to a few of these sessions in the past but I've never seen one as packed out as this one. It was great to see such a turn-out, which no doubt was boosted by the presence of both the <a href="http://www.qmsdnug.org/" title="QMSDNUG">Queensland MSDN Users Group</a> and the <a href="http://bfpg.org/" title="BFPG">Brisbane Functional Programming Group</a>. </p>
<p>The talk was covering <a href="http://en.wikipedia.org/wiki/Functional_programming" title="Functional Programming">Functional Programming</a> and the <a href="http://en.wikipedia.org/wiki/NoSQL" title="NoSQL">NoSQL</a> movement (which, as Dave himself puts it, should be called <em>NoRDB</em>). These are two areas of computing that are currently key interests of mine, so it won't come as a surprise to find that I thoroughly enjoyed the talk. I certainly wasn't the only one. Dave did such a great job of covering the positives of these two movements that we're already seeing more and more people signing up for membership to <a href="http://bfpg.org/" title="BFPG">BFPG</a>.</p>
<p>I'm not going to go into the gory details about what Dave covered in his talk as I don't want to spoil it for other people if he plans on doing it again elsewhere. There are a few things I would like to mention though:</p>
<ul>
<li>Functional Programming is here to stay. If you're not familiar with it, or haven't yet taken a look at it, I suggest you get started!</li>
<li>If you're looking to get involved with FP and you're in or around the Brisbane area, be sure to come to one of our <a href="http://bfpg.org/" title="BFPG">BFPG</a> meetups.</li>
<li>Don't fall into the trap of assuming that if your system needs a back-end data store that an <a href="http://en.wikipedia.org/wiki/Relational_database_management_system" title="Relational Database Management System">RDBMS</a> is the only option, because it's not!</li>
</ul>
<p>This talk has inspired me to not only continue checking out the likes of <a href="http://haskell.org/" title="Haskell">Haskell</a>, <a href="http://erlang.org/" title="Erlang">Erlang</a> and <a href="http://riak.basho.com/" title="Riak">Riak</a>, it's pointed me at some languages that I never knew existed. Languages which are insanely powerful, very dense, yet still extremely useful. Some examples are <a href="http://en.wikipedia.org/wiki/J_(programming_language)" title="J">J</a>, <a href="http://en.wikipedia.org/wiki/K_(programming_language)" title="K">K</a> and <a href="http://en.wikipedia.org/wiki/Q_(programming_language_from_Kx_Systems)" title="Q">Q</a>. <a href="http://www.kx.com/products/database.php" title="KDB+">KDB+</a> in particular is very interesting as it ties in with the use of another type of technology that I was aware of but knew nothing about: <a href="http://en.wikipedia.org/wiki/Column-oriented_DBMS" title="Column Database">Column Databases</a>. Crazy stuff.</p>
<p>After seeing so many people excited by the prospect of Functional Programming after Dave's talk had concluded, I decided to set up a new website for <a href="http://bfpg.org/" title="BFPG">BFPG</a> so that we had a proper home rather than just a spot on <a href="www.meetup.com/Brisbane-Functional-Programming-Group-BFG/" title="BFPG @ Meetup.com">Meetup.com</a>. Check it out and feel free to send through some feedback if you have any, or <a href="http://bfpg.org/contact/" title="Contact BFPG">drop us a line</a> if you have any ideas for talks or would like to present something yourself.</p>
<p>That's it for today's brain-fart <img src='http://buffered.io/wp-content/plugins/smilies-themer/Silk/emoticon_smile.png' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://buffered.io/2010/05/22/dave-thomas-at-yow-nights-brisbane/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I&#8217;m so impressed I want to pay you less</title>
		<link>http://buffered.io/2010/03/02/im-so-impressed-i-want-to-pay-you-less/</link>
		<comments>http://buffered.io/2010/03/02/im-so-impressed-i-want-to-pay-you-less/#comments</comments>
		<pubDate>Tue, 02 Mar 2010 02:27:46 +0000</pubDate>
		<dc:creator>OJ</dc:creator>
				<category><![CDATA[Being in the Industry]]></category>
		<category><![CDATA[Erlang]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://buffered.io/?p=805</guid>
		<description><![CDATA[The title of this post is a statement that I've heard a few times in the past while at work. The people who said it might not have used those exact words, but the intent is the same. Usually I hear it in the following form: "We're very happy with the work you've done for [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://buffered.io/wp-content/uploads/2010/03/statue-of-liberty_whip_ny-times.jpg" title="Slave driver" rel="lightbox[slave]"><img src="http://buffered.io/wp-content/uploads/2010/03/statue-of-liberty_whip_ny-times.jpg" alt="Slave driver" title="Slave driver" width="150" style="float: left; margin-bottom: 5px; margin-right: 5px;"/></a>The title of this post is a statement that I've heard a few times in the past while at work. The people who said it might not have used those exact words, but the intent is the same. Usually I hear it in the following form:</p>
<p><em>"We're very happy with the work you've done for us as a contractor. We want to keep you on, but would like you to take a job as a permanent employee and continue to work on the project."</em></p>
<p>Once they've made this point, they then feel the need to harp on about the good points of becoming a permanent employee. Things such as job security, sick/annual leave and better hours tend to get mentioned. All of them are complete bullshit of course.</p>
<p>There is <strong>no such thing as job security</strong>. Sick and/or annual isn't enough to make up for the difference in pay. Hours tend to always be worse when you're working for the man, because you're expected to do whatever needs to be done regardless of the hours. This is worse if you're working on mission-critical stuff. </p>
<p>Now I have no aversion to doing my fair share of extra work and mission-critical stuff is way more interesting. I often enjoy it. What I don't enjoy is the expectation for me to give away my free time to my employer for no reward. I don't get extra time off in lieu. I don't get overtime pay. I don't get ownership of the software. I don't get to see the result of the extra effort I put in. I'm just expected to do it. In other situations I'd be happy to do it, but 999 times out of 1000, the situation isn't right.</p>
<p>I've even worked for companies in the past who expect you to give up a lot of your personal time even if there isn't anything critical that needs to be done. I was expected to write small applications and create other assets that the company could use in future projects. At first this seemed like it could be fun. But the cold hard reality was that all of the effort was totally wasted, because none of the things that were created ever got used.</p>
<p>As a contractor, the view from the perspective of the client is different, especially if you're on an hourly rate. Everything boils down to a financial cost. You're more likely to get a fair deal as a contractor than you are as a permy (at least here in the Brisbane market) because you're entitled to make them pay for the time and effort you put in.</p>
<p><a href="http://buffered.io/wp-content/uploads/2010/03/cartoon_farcus.gif" title="Slave of the month" rel="lightbox[slave]"><img src="http://buffered.io/wp-content/uploads/2010/03/cartoon_farcus.gif" alt="Slave of the month" title="Slave of the month" width="150" style="float: right; margin-bottom: 5px; margin-left: 5px;"/></a>I realise that this makes me sound rather mercenary. In all honesty, I'm not mercenary. I love technology. I love building software. I don't go to work just so that I can get paid. In many ways I would work for less pay if the conditions were right. Unfortunately, I am yet to come across a job where those conditions are right. I've certainly given it a shot in the past. I took a substantial pay-cut to work for Electronic Arts back in 2005 so that I could work on something that I really wanted to work on. I thoroughly enjoyed it. As far as the technology and the challenges are concerned, it's the most fun I've ever had at work. Unfortunately, the experience I had there led me to believe that the lifestyle isn't sustainable (at least not for me and my family).</p>
<p>Would I do the same again for another job? Definitely. But the only company I would do it for would be <a href="http://basho.com/" title="Basho">Basho</a> and my <a href="http://erlang.org/" title="Erlang">Erlang-fu</a> is not yet up to scratch so I wouldn't be considered. Outside of Basho I'm not aware of any other company or work that excites me as much. So for now I will probably remain a contractor, and try to move around and add as much value as I can on a variety of projects, keeping up to speed on many different types of technology.</p>
<p>So if you're reading this, give me a few good reasons as to why permanent work is better than contract work. Why should I consider it? Would you consider it? If you're a permy, are you looking to go contracting, and why?</p>
<p>Feedback and comments are appreciated <img src='http://buffered.io/wp-content/plugins/smilies-themer/Silk/emoticon_smile.png' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://buffered.io/2010/03/02/im-so-impressed-i-want-to-pay-you-less/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
		<item>
		<title>The Wrong Decision by the Wrong Person</title>
		<link>http://buffered.io/2010/01/28/the-wrong-decision-by-the-wrong-person/</link>
		<comments>http://buffered.io/2010/01/28/the-wrong-decision-by-the-wrong-person/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 12:35:29 +0000</pubDate>
		<dc:creator>OJ</dc:creator>
				<category><![CDATA[Being in the Industry]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[WTF]]></category>
		<category><![CDATA[bad decisions]]></category>
		<category><![CDATA[software developer]]></category>

		<guid isPermaLink="false">http://buffered.io/?p=796</guid>
		<description><![CDATA[There is one thing about my industry that I still find truly amazing (and not in a good way). This is despite the fact that it has happened to me so many times that you think I'd be used to it! I'm talking about non-technical people making technical decisions. For some reason, it's a very [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://buffered.io/wp-content/uploads/2010/01/pizza.jpg" title="The wrong tool." rel="lightbox"><img src="http://buffered.io/wp-content/uploads/2010/01/pizza.jpg" alt="The wrong tool." title="The wrong tool." style="float:right; margin-left:5px; margin-bottom:5px;"  width="150"/></a>There is one thing about my industry that I still find truly amazing (and not in a good way). This is despite the fact that it has happened to me so many times that you think I'd be used to it! I'm talking about non-technical people making technical decisions.</p>
<p>For some reason, it's a very common practice for those people who don't have expertise in a certain field to make decisions for people working in that field. The best example I can think of off the top of my head is the answer to the question: <em>"Which technology should we use?"</em></p>
<p>Let me take a step back in time for a moment. </p>
<p>I applied for a job with a certain company (which shall remain nameless) that was looking for a number of C#/.NET developers of a certain level of experience. After confirming an interview date and time, I turned up to find myself facing a panel of 3 interviewers. One of those people held a technical position, though I found out later that the position he held was self-appointed and certainly not an indication of the person's level of technical knowledge or expertise. The other two were in non-technical positions.</p>
<p>During the interview we had the usual discussions and questions around technial knowledge, depth of understanding of certain areas of the .NET framework, views and approaches to dealing with people in teams, agile experience, etc. It all went very well. At the end of the interview I was given my chance to ask a few questions. The main one I wanted to ask was <em>"Why did you decide to use .NET for this project?"</em></p>
<p>For the record, the <em>previous</em> version of the system was written using an older Microsoft technology stack. The decision had been made to go with .NET for this new version. Can you see the correlation?</p>
<p>The answer was quite stunning. The only reason the project was using .NET was because the previous version was a Microsoft-based solution.</p>
<p>The first thing I thought was "surely that can't be it?". As a matter of fact, that wasn't the <em>only</em> reason for it, but it was the <em>main</em> reason. The decision wasn't made by a technical person, it was made by someone in upper management.</p>
<p>Scary huh!?</p>
<p>In my personal opinion, there is one particular technology that I think would have done a much better job of solving this particular problem, and it's not a Microsoft solution. It's not a Sun solution, or any other mainstream option for that matter. In my view, <strong>Erlang</strong> would have been perfect.</p>
<p>I don't think that a company like that would have ever even considered Erlang as a viable option. Mainly for two reasons. The first is that the amount of skilled Erlang developers available on the East Coast of Australia is extremely small. The second is fear of the unknown/non-mainstream tech. That is, companies like to go with what other companies are going with.</p>
<p>The crazy thing about this scenario is that management go to market to hire people who are domain experts, and then proceed to tell them which technologies to use. Surely you would be better off hiring people to know how to solve problem X really well, and then listen to what they have to say about the technology stack that should be put in place? No, not in this industry. Probably not in my lifetime either!</p>
<p>So if you're a non-tech person leading a team of techies, please PLEASE listen to what they have to say. Ask them what they think is the right approach and the right toolset. Don't take control of the technical decisions. Let them do what you hired them to do: Solve the problem, and use the right tool for the job. If they don't know the answer, or the answer is always the same, then you've got the wrong developers.</p>
<p>Thanks for listening <img src='http://buffered.io/wp-content/plugins/smilies-themer/Silk/emoticon_smile.png' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://buffered.io/2010/01/28/the-wrong-decision-by-the-wrong-person/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Katacast: Shopping Checkout in Erlang</title>
		<link>http://buffered.io/2010/01/04/katacast-shopping-checkout-in-erlang/</link>
		<comments>http://buffered.io/2010/01/04/katacast-shopping-checkout-in-erlang/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 07:47:05 +0000</pubDate>
		<dc:creator>OJ</dc:creator>
				<category><![CDATA[Erlang]]></category>
		<category><![CDATA[Functional Programming]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[codekata]]></category>
		<category><![CDATA[katacast]]></category>
		<category><![CDATA[rake]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://buffered.io/?p=785</guid>
		<description><![CDATA[I've recently discovered the joys of CodeKatas. If you're a geek looking for a way to sharpen your saw then I highly recommend taking a look at these and trying a few out. They're great fun and they're a good way of getting your feet wet with new languages (especially if you're tired of Project [...]]]></description>
			<content:encoded><![CDATA[<p>I've recently discovered the joys of <a href="http://codekata.pragprog.com/" title="CodeKata">CodeKatas</a>. If you're a geek looking for a way to <a href="http://en.wikipedia.org/wiki/The_Seven_Habits_of_Highly_Effective_People" title="The Seven Habits of Highly Effective People">sharpen your saw</a> then I highly recommend taking a look at these and trying a few out. They're great fun and they're a good way of getting your feet wet with new languages (especially if you're tired of <a href="http://projecteuler.net/" title="Project Euler">Project Euler</a>). </p>
<p>I can thank <a href="http://twitter.com/gabriellelana" title="Gabrielle on Twitter">Gabrielle Lana</a> for this discovery, as it was his <a href="http://www.vimeo.com/8206748" title="String Calculator in Erlang">attempt at one of the katas</a> that got me into it. He's also the reason I looked into <a href="http://www.katacasts.com/" title="Katacasts">Katacasts</a>, which are simply screencasted recordings of people attempting to solve Code Katas.</p>
<p>This post is about my first Katacast, capturing my attempt at <a href="http://codekata.pragprog.com/2007/01/kata_nine_back_.html" title="Checkout">Code Kata #9</a> using <a href="http://erlang.org/" title="Erlang">Erlang</a> and <a href="http://vim.org/" title="VIM">VIM</a> with <a href="http://rake.rubyforge.org/" title="Ruby Make">Rake</a> as my build system. I've put the video up on <a href="http://vimeo.com/8513414" title="Katacast for Codekata #9 by OJ Reeves">Vimeo</a> for the world to see/share. It's also embedded below for your convenience.</p>
<p>Before watching, I'd like to point out a few things about the video, and things that I have learned from the experience:</p>
<ul>
<li>I captured the video on my Linux Mint install. For some reason, capturing quality video in Linux is proving to be a bit of a pain for me. As a result, the video quality isn't that great. This partly due to the compression of the video, and partly due to the software failing to pick up some screen updates.</li>
<li>I tried really hard to add a backing sound-track but all of my efforts failed in one way or another. If I did manage to get one to work it was either WAY too big (ie. > 1GB in size) or the quality was absolutely terrible.</li>
<li>There were points during the process where I had to alt-tab out to a browser to do a bit of research on something that I didn't know (such as an Erlang syntax quirk). This resulted in a few points where I don't appear to be doing anything. In future, I'll remember to hit pause on the recording when this happens.</li>
<li>I captured it in a non-standard resolution. I'm not sure if that's going to make it look bad or not. Feedback here is appreciated. I think in future I'll capture at a 800x600 resolution.</li>
<li>This video is best viewed in full-screen mode.</li>
</ul>
<p>So please excuse the lack of quality in this first Katacast. I'll be sure to improve when I next create one. That being said, on with the show!</p>
<div style="margin-left: auto; margin-right: auto; width: 400px;"><object width="400" height="300"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=8513414&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=8513414&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="300"></embed></object><br />
<a href="http://vimeo.com/8513414">Katacast for Codekata #9</a> from <a href="http://vimeo.com/thecolonial">OJ Reeves</a> on <a href="http://vimeo.com">Vimeo</a>.</div>
<p>As always, feedback/criticism/etc is greatly appreciated. I'd love to hear what you guys do and use to capture and edit your screencasts, particularly in Linux.</p>
]]></content:encoded>
			<wfw:commentRss>http://buffered.io/2010/01/04/katacast-shopping-checkout-in-erlang/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>It&#8217;s OK to Fail</title>
		<link>http://buffered.io/2009/12/11/its-ok-to-fail/</link>
		<comments>http://buffered.io/2009/12/11/its-ok-to-fail/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 05:42:38 +0000</pubDate>
		<dc:creator>OJ</dc:creator>
				<category><![CDATA[Being in the Industry]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Fail]]></category>
		<category><![CDATA[ignorance]]></category>
		<category><![CDATA[stagnation]]></category>

		<guid isPermaLink="false">http://buffered.io/?p=775</guid>
		<description><![CDATA[Yes. You read that right. It's OK to fail. Yes, I am talking to you. You... that guy who is part of every team. The one who seems to feel the need to be right about everything. The one who thinks that everything new has already been done 15 years prior. The one who believes [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://buffered.io/wp-content/uploads/2009/12/EpicFail02.jpg" title="Epic Fail" rel="lightbox[775]"><img src="http://buffered.io/wp-content/uploads/2009/12/EpicFail02.jpg" alt="Epic Fail" width="160" style="float:left;padding-bottom:5px;padding-right:5px;" /></a><em>Yes. You read that right. It's OK to fail. Yes, I am talking to you. You... that guy who is part of every team. The one who seems to feel the need to be right about everything. The one who thinks that everything new has already been done 15 years prior. The one who believes that every project they have participated in has been a profound success, and that a project-level failure (which includes missing deadlines or blowing the budget) is something they have never experienced. Failure is not only OK, it's something that you <strong>must</strong> experience somewhere along the way so you know when you've succeeded.</em> </p>
<p><em>It's safe to admit that you just don't know! In fact, it's <strong>better</strong> if you do admit it. Pretending that you know what you don't not only makes you the butt of the jokes, but you end up being detrimental to the success of the project.</em></p>
<p><em>Stop trying to be a know-all. Let go of the idea that you need to be the one to approve everything. Take a step back and be honest to yourself and the rest of the team. You aren't a one-man-band. You aren't the technical guru that you think you are. You aren't even a specialist in a particular area, let alone a jack-of-all-trades.</em></p>
<p><em>When you attempt to do something and you fail, stop trying to make it sound like you haven't failed. Please stop yourself from trying to turn your wrong into a right. <strong>Everyone</strong> fails in one way or another during their working life, and as much as you don't want to admit it, it does include you.</em></p>
<p><em>Change your attitude. You'll be doing yourself a favour.</em></p>
<p><em>And while you're at it, how about you get up to speed with the technology you're working with. Then you won't have to pretend, and the likelihood of you failing will start to decrease.</em></p>
<p><em>Thanks for listening.</em></p>
<hr />
This might seem like an angry rant. I admit it is a little. It's not directed at one particular person. It's aimed at a particuar type, or breed, of person. One that seems to appear in every gig that I work on. This kind of individual can be a bad apple in a barrel of good apples who over time causes long-term rot and frustration amongst the team. Velocity can be seriously affected. Productivity can plummet.</p>
<p>Remember, it's not about you, it's all about the <strong>software</strong>.</p>
]]></content:encoded>
			<wfw:commentRss>http://buffered.io/2009/12/11/its-ok-to-fail/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>The Future is Erlang</title>
		<link>http://buffered.io/2009/10/31/the-future-is-erlang/</link>
		<comments>http://buffered.io/2009/10/31/the-future-is-erlang/#comments</comments>
		<pubDate>Sat, 31 Oct 2009 10:28:10 +0000</pubDate>
		<dc:creator>OJ</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Erlang]]></category>
		<category><![CDATA[Functional Programming]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Mercurial]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Webmachine]]></category>

		<guid isPermaLink="false">http://buffered.io/?p=769</guid>
		<description><![CDATA[For quite a while I've been using my spare cycles to chew over a problem. This problem is not one that hasn't been solved before, but one that I feel can be solved in a much better way. From the bit of research that I've done, I can see at least three areas which can [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://buffered.io/wp-content/uploads/2009/10/erlang.png" alt="erlang" title="erlang" style="float:left;margin-right:5px;margin-bottom:5px;" />For quite a while I've been using my spare cycles to chew over a problem. This problem is not one that hasn't been solved before, but one that I feel can be solved in a much better way. From the bit of research that I've done, I can see at least three areas which can be improved on dramatically. So I've decided, after a long period of deliberation, to go ahead and build my solution and release it to the world as a service!</p>
<p>I know, this kind of thing happens thousands of times a day. Some arbitrary geek decided to build the next killer app and expects to make a crapload of cash out of it. While that would be nice, the ultimate goal isn't the cash. The goal for me is to build something that gets used, and for me to begin to master an area of technology that I've had a quiet passion for for a long period of time now.</p>
<p>My plan is simple. While learning the technologies that I will be using I'll be building another application and blogging about it so that all of you can learn with me. Meanwhile, I shall use my learnings to build this other application at the same time.</p>
<p>The final result should be a series of posts which help other people learn the technology stack, give better coverage and visibility to languages and technologies that a lot of the geek world doesn't know about (and really should!), and for me to carve myself a bit of a niche here on the East coast of Ozland. I am hoping to be able to consult my services out to other businesses as a result.</p>
<p>For those that are interested in following along, here is the full tech stack and toolset that I'll be using:</p>
<ul>
<li><a href="http://erlang.org/" title="Erlang">Erlang</a> - A fantastic cross-platform functional programming language that has some amazing features.</li>
<li><a href="http://bitbucket.org/justin/webmachine/" title="Webmachine HTTP toolkit">Webmachine</a> - A HTTP toolkit which sits on top of <a href="http://code.google.com/p/mochiweb/" title="Mochiweb">Mochiweb</a> that makes it easy to build well-behaved HTTP applications.</li>
<li><a href="http://nitrogenproject.com/" title="Nitrogen Framework">Nitrogen</a> - An Erlang-based framework that makes it easy to build websites.</li>
<li><a href="http://riak.basho.com/" title="Riak">Riak</a> or <a href="http://couchdb.apache.org/" title="CouchDB">CouchDB</a> - Both of these amazing pieces of tech are potential candidates for the back-end storage. I'm not yet sure which one I'll go with.</li>
<li><a href="http://jquery.com/" title="jQuery">jQuery</a> - A great JavaScript library for the front-end.</li>
<li><a href="http://vim.org/" title="VIM text editor">VIM</a> - My favourite text editor <img src='http://buffered.io/wp-content/plugins/smilies-themer/Silk/emoticon_smile.png' alt=':)' class='wp-smiley' /> </li>
<li><a href="http://www.xubuntu.org/" title="Xubuntu">Xubuntu</a> - Ubuntu <a href="http://ubuntu.com/" title="Ubuntu 9.10">Karmic Koala</a> with <a href="http://www.xfce.org/" title="XFCE">XFCE</a> as the window manager.</li>
<li><a href="http://mercurial-scm.org/" title="Mercurial SCM">Mercurial</a> - My favourite version control system.</li>
<li><a href="http://trac.edgewall.org/" title="The Trac Project">Trac</a> - A project tracking tool.</li>
<li><a href="http://www.virtualbox.org/" title="VirtualBox">VirtualBox</a> - My choice for virtualisation. I tend to run Windows 7 as my primary OS, so most of my dev will be in a VM. When I get my desktop machine back up and running (with all three monitors!) it'll most likely multiboot Win 7 and Xubuntu.
<li><a href="http://wave.google.com/" title="Google Wave">Google Wave</a> - I'll be using this for communications with some really switched on people in the Erlang community who have kindly offered to help me with questions and whatnot specific to some of the areas of tech I've mentioned above.</li>
</ul>
<p>During the course of my blogging/learning I'll be focussing on Webmachine, Riak/CouchDB, Erlang and Nitrogen. All the other tools will probably get mentioned along the way, but the primary goal is to focus on these things.</p>
<p>I'm really excited! I'm currently in the process of documenting my goals and the design for the main application. Once that's done, I'll get started with the fun stuff. I've got a lot to do and it should be a fun ride. I hope you enjoy following along!</p>
]]></content:encoded>
			<wfw:commentRss>http://buffered.io/2009/10/31/the-future-is-erlang/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>The Value of a Technical Community</title>
		<link>http://buffered.io/2009/07/29/the-value-of-a-technical-community/</link>
		<comments>http://buffered.io/2009/07/29/the-value-of-a-technical-community/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 21:30:29 +0000</pubDate>
		<dc:creator>OJ</dc:creator>
				<category><![CDATA[Being in the Industry]]></category>
		<category><![CDATA[Haskell]]></category>
		<category><![CDATA[Mercurial]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[anger]]></category>
		<category><![CDATA[community]]></category>
		<category><![CDATA[irc]]></category>
		<category><![CDATA[value]]></category>

		<guid isPermaLink="false">http://buffered.io/?p=737</guid>
		<description><![CDATA[This post was inspired by an experience I had recently in an IRC channel. To protect the innocent, I'll refrain from naming and shaming the channel and individual as those details aren't important. Communities are arguably the life blood of technology. Without a good community the likelihood of the technology catching on is drastically reduced. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://buffered.io/wp-content/uploads/2009/07/community.jpg" title="Cricket Team Holding Hands --- Image by © Royalty-Free/Corbis" rel="lightbox[737]"><img src="http://buffered.io/wp-content/uploads/2009/07/community-150x150.jpg" alt="Cricket Team Holding Hands --- Image by © Royalty-Free/Corbis" title="Cricket Team Holding Hands --- Image by © Royalty-Free/Corbis" width="150" style="float: left; margin-right: 5px; margin-bottom: 5px;" /></a>This post was inspired by an experience I had recently in an IRC channel. To protect the innocent, I'll refrain from naming and shaming the channel and individual as those details aren't important.</p>
<p>Communities are arguably the life blood of technology. Without a good community the likelihood of the technology catching on is drastically reduced. Those communities which lack individuals that are happy to put time and effort in to help get others up to speed tend to stagnate. Any community which involves members that are abrasive, rude and downright offensive is destined to suffer long term. </p>
<p>The level of suffering will vary depending on quite a few things. Those things include existing user base, the age of the technology and the number of different ways that a given <acronym title="New person">n00b</acronym> can get information about that technology.</p>
<p><a href="http://en.wikipedia.org/wiki/Internet_Relay_Chat" title="IRC">IRC</a> is a very common and popular means for members of communities to interact. It provides a real-time element that you don't get with blogs, forums and other media like <a href="Twitter" title="http://twitter.com/">Twitter</a>. It satisfies every geek's desire to get the answer and get it <strong>now</strong>. Experiencing support in real time via IRC can be extremely helpful and rewarding. It can work wonders for the popularity and image of the community and the technology itself.</p>
<p>If you're interested in seeing some active and extremely helpful communities, you should take a look at <a href="irc://chat.freenode.net/haskell" title="#haskell on freenode">#haskell</a> and <a href="irc://chat.freenode.net/mercurial" title="#mercurial on freenode">#mercurial</a>. Both of these channels are generally very active. The people that spend time in them are both helpful and friendly. Both of these channels indicate to me that there is a very healthy and vibrant community behind each of these pieces of technology.</p>
<p><a href="http://buffered.io/wp-content/uploads/2009/07/anger.jpg" title="ARGH!" rel="lightbox[737]"><img src="http://buffered.io/wp-content/uploads/2009/07/anger.jpg" width="200" alt="ARGH!" title="ARGH!" style="float: right; margin-left: 5px; margin-bottom: 5px;"/></a><br />
Unfortunately, this kind of communication also has a downside. The real-time nature of IRC allows people to vent anger on newcomers without any means of moderation. The net result of this is that other individuals become to scared to offer their view or provide support for fear of receiving the same treatment. This goes for members with any level of skill or knowledge. There are some community channels out there containing hundreds of people, and yet there is no conversation. When questions are asked, nobody responds.</p>
<p>After my recent experience in a channel that fist this description, it's easy to see why. In less that half an hour of asking for clarification on certain points, I received a barrage of abuse which, in my view, was <strong>totally unjustified</strong>.</p>
<p>But let's say, for the sake of argument, that it was justified. That for some reason I annoyed someone in such a way that bombarding me with many 4 and 5-letter expletives was acceptable. Do <em>you</em> think that it paints a good picture of the community?</p>
<p><strong>I think <em>not</em>.</strong></p>
<p>In less than half an hour I went from excited to deflated. I lost interest in the piece of technology and lost faith in the community around it. Was my response justified or understandable?</p>
<p>I'm not sure about the answer to this <img src='http://buffered.io/wp-content/plugins/smilies-themer/Silk/emoticon_smile.png' alt=':)' class='wp-smiley' /> </p>
<p>I feel that it's the job of the community to moderate other members of their community. If people get abusive then other members should step in and prevent it. In my case this wasn't possible due to the fact that the person in question was abusing me via a private chat so that the channel couldn't witness his venting. I'm guessing this wasn't the first time that he's done this to someone, nor will it be the last. I wonder how many others have suffered the same fate? If the silence of the channel is anything to go by, I'm guessing quite a few.</p>
<p>I guess what I'm trying to say here is this: don't underestimate the value and importance of your community. It's one of the most frequented faces of your technology. If it's bitter, unwelcoming and unsupportive, you will not only lose valuable newcomers who come looking for information and support, you will also lose future users due to the poor reputation. Ultimately, your tech will suffer.</p>
<p>If you're part of a community, do your bit to police it. Help those who need help. Stop those people who are abusive.</p>
<p>.. and if you don't have anything nice to say, then <em>don't say anything at all</em>!</p>
<p>
<!-- Begin Google Adsense code -->
<p><center>
<script type="text/javascript"><!--
google_ad_client = "pub-5662448744756930";
/* 468x60, created 2/11/09 */
google_ad_slot = "8047929723";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></center></p>
<!-- End Google Adsense code -->
</p>
]]></content:encoded>
			<wfw:commentRss>http://buffered.io/2009/07/29/the-value-of-a-technical-community/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Point-Free style: What is it good for?</title>
		<link>http://buffered.io/2009/06/27/point-free-style-what-is-it-good-for/</link>
		<comments>http://buffered.io/2009/06/27/point-free-style-what-is-it-good-for/#comments</comments>
		<pubDate>Sat, 27 Jun 2009 11:49:43 +0000</pubDate>
		<dc:creator>OJ</dc:creator>
				<category><![CDATA[Functional Programming]]></category>
		<category><![CDATA[Haskell]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Point Free]]></category>
		<category><![CDATA[style]]></category>

		<guid isPermaLink="false">http://buffered.io/?p=724</guid>
		<description><![CDATA[If you're not interested in what inspired this post, then skip this section and jump to the more interesting bits. A little bit of history... Recently I've been delving into Haskell quite a bit. It's part of my apparently never-ending quest to learn as much as I can about as many languages as I can [...]]]></description>
			<content:encoded><![CDATA[<p>If you're not interested in what inspired this post, then skip this section and <a href="#MoreInteresting" title="The purpose of the post">jump</a> to the more interesting bits.</p>
<h3>A little bit of history...</h3>
<p>Recently I've been delving into <a href="http://haskell.org/" title="Haskell">Haskell</a> quite a bit. It's part of my apparently never-ending quest to learn as much as I can about as many languages as I can (well, those that appeal to me at least :)). While I love playing around with a language, toying with ideas, writing small programs, reading books, blog posts, etc it's not really the same as having an on-call expert to help and guide you. </p>
<p> While I'm aware of, and frequently visit, the <a href=http://www.haskell.org/haskellwiki/IRC_channel" title="Haskell IRC">Haskell IRC channell</a> I find that the level of understanding there is so great that my piddly <a href="http://en.wikipedia.org/wiki/Newbie" title="Newbie">noob</a> questions tend to get lost amongst the bombardment of much more advanced &#038; interesting discussions. In short, while I find it a great place to go, it's not a great place to find someone who's happy to help guide me through the maze and go over topics in quite a bit of detail while I annoy them with questions.</p>
<p>Haskell is one of those languages where having a mentor is really beneficial. So I set about finding myself one. Thankfully, I found a rather helpful chap based in the UK, <del>(he shall remain anonymous, as I don't want to violate the man's privacy)</del>, <a href="http://twitter.com/peter_marks" title="Peter Marks">Peter Marks</a>, who has been very forthcoming with information. He's humoured me and been incredibly patient so far, and I'm very grateful for his time.</p>
<p>One of the questions that I asked him was:<br />
<blockquote cite="OJ">
<p>Why is it that everyone seems to strive to get their code into <a href="http://www.haskell.org/haskellwiki/Pointfree" title="Point Free">Point-Free</a> style? I can see how a lot of the implementations are more concise, but many of those lose readability.</p>
<p>What is so special about it?</p>
</blockquote>
<p>The discussion that followed was really insightful. That is what has inspired me to write this post.</p>
<p>Please note, any errors in this post are totally my own. They are not the fault of my mentor <img src='http://buffered.io/wp-content/plugins/smilies-themer/Silk/emoticon_smile.png' alt=':)' class='wp-smiley' /> </p>
<h3 id="MoreInteresting">The purpose of the post: Why aim for Point-Free style?</h3>
<p>So it is just me, or does anyone else out there feel that there's a bit of a "thing" going on for Point-Free style? Sometimes I share my terrible code with people and I get shunned when it's not Point-Free and it could be.</p>
<p>Anyone?</p>
<p>I hope it's not just me <img src='http://buffered.io/wp-content/plugins/smilies-themer/Silk/emoticon_smile.png' alt=':)' class='wp-smiley' /> Let's start with taking a quick look at what Point-Free style actually is.</p>
<h4>So what is Point-Free style?</h4>
<p>If we take a look at the <a href=http://en.wikipedia.org/wiki/Point-free_programming" title="Wikipedia">Wikipedia</a> we can see that..<br />
<blockquote>
<p>Tacit [point-free] programming is a programming paradigm in which a function definition does not include information regarding its arguments, using combinators and function composition (but not ?-abstraction) instead of variables.</p>
</blockquote>
<p>Simple eh? <img src='http://buffered.io/wp-content/plugins/smilies-themer/Silk/emoticon_smile.png' alt=':)' class='wp-smiley' /> In essence, it basically means that your function definition doesn't reference any of its arguments/variables. For a crass definition, think <em>point == argument</em> and it should make sense.</p>
<p>So we're writing functions without directly referencing its arguments. For those not familiar with Haskell or other languages that support this, let's take a look at an example:</p>

<div class="wp_syntax"><div class="code"><pre class="haskell" style="font-family:monospace;"><span style="color: #5d478b; font-style: italic;">-- sum : take a list of numbers and add them all up to get a total</span>
<span style="color: #5d478b; font-style: italic;">-- start with the base-case: an empty list</span>
<span style="font-weight: bold;">sum</span> <span style="color: green;">&#91;</span><span style="color: green;">&#93;</span> <span style="color: #339933; font-weight: bold;">=</span> <span style="color: red;">0</span>
<span style="font-weight: bold;">sum</span> <span style="color: green;">&#40;</span>x:xs<span style="color: green;">&#41;</span> <span style="color: #339933; font-weight: bold;">=</span> x <span style="color: #339933; font-weight: bold;">+</span> <span style="font-weight: bold;">sum</span> xs</pre></div></div>

<p>We can see that the above function is written in such a way that the arguments passed into the function are actually referenced in the body of the code. This is how a standard imperative programmer would write this function if he/she was new to Haskell. If we instead used a <a href="http://www.haskell.org/haskellwiki/Fold" title="Fold">fold</a>, we could define it like so:</p>

<div class="wp_syntax"><div class="code"><pre class="haskell" style="font-family:monospace;"><span style="font-weight: bold;">sum</span> xs <span style="color: #339933; font-weight: bold;">=</span> <span style="font-weight: bold;">foldr</span> <span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">+</span><span style="color: green;">&#41;</span> <span style="color: red;">0</span> xs</pre></div></div>

<p>This does exactly the same thing as the previous definition, but as you can see the grunt work is done by the fold function. Now that we have this definition, we can easily move to Point-Free style:</p>

<div class="wp_syntax"><div class="code"><pre class="haskell" style="font-family:monospace;"><span style="font-weight: bold;">sum</span> <span style="color: #339933; font-weight: bold;">=</span> <span style="font-weight: bold;">foldr</span> <span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">+</span><span style="color: green;">&#41;</span> <span style="color: red;">0</span></pre></div></div>

<p>Here we can see that no reference is made to the arguments of the function. Since we haven't referenced any "points", we have a Point-Free implementation.</p>
<p>Awesome. Cool. Sweet. Nifty.</p>
<p>But what does it give me? Why is it better?</p>
<h4>Why use Point-Free style?</h4>
<p>This section is based totally on my own opinion and is not an official definition <img src='http://buffered.io/wp-content/plugins/smilies-themer/Silk/emoticon_smile.png' alt=':)' class='wp-smiley' /> I think that Point-Free style fits in the same category as many other coding patterns and styles, and that it's usually down to the individual programmer to determine the when and the why. So take my view with a pinch of salt.</p>
<p>In short, Point-Free style let's you <em>focus on the <strong>how</strong> rather than the <strong>what</strong></em>.</p>
<p>It might be just me, but imperative programs seem to have a large focus on the data. The code which operates on the data is lost within a plethora of code that isn't necessarily specific to what the program needs to do. I've found that functional programming tends to be very different, at least in Haskell. Haskell lets me focus on what it is I need to do, and I feel that Point-Free is another step in the same direction. Is this good? I think so <img src='http://buffered.io/wp-content/plugins/smilies-themer/Silk/emoticon_smile.png' alt=':)' class='wp-smiley' /> But I'll let you decide.</p>
<p>As well as the focus on the <strong>what</strong> I've found that aiming for a Point-Free solution can aid in helping you understand your problem better. This claim sounds like fluff, so let's go through an example and hopefully you'll see what I mean.</p>
<h4>Where Point-Free helped me get a better understanding</h4>
<p>Haskell developers use the <a href="http://www.haskell.org/haskellwiki/Function_composition" title="Function composition">composition operator</a> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/src/GHC-Base.html#." title="(.) implementation in Prelude">(.)</a> a lot. It actually aids in creating Point-Free style. I love the irony here. We add points (.) to remove points (arguments).</p>
<p>Anyway, the composition operator's definition, according to <a href="http://www.haskell.org/onlinereport/standard-prelude.html" title="Prelude">Prelude</a> is:</p>

<div class="wp_syntax"><div class="code"><pre class="haskell" style="font-family:monospace;"><span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">.</span><span style="color: green;">&#41;</span>       <span style="color: #339933; font-weight: bold;">::</span> <span style="color: green;">&#40;</span>b <span style="color: #339933; font-weight: bold;">-&gt;</span> c<span style="color: green;">&#41;</span> <span style="color: #339933; font-weight: bold;">-&gt;</span> <span style="color: green;">&#40;</span>a <span style="color: #339933; font-weight: bold;">-&gt;</span> b<span style="color: green;">&#41;</span> <span style="color: #339933; font-weight: bold;">-&gt;</span> a <span style="color: #339933; font-weight: bold;">-&gt;</span> c
<span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">.</span><span style="color: green;">&#41;</span> f g x <span style="color: #339933; font-weight: bold;">=</span> f <span style="color: green;">&#40;</span>g x<span style="color: green;">&#41;</span></pre></div></div>

<p>This operator takes two functions and produces a function which is composed of the two. This function takes the output of one function and sends it through as the input to another function, returning the result of that call.</p>
<p>This is really handy. We can do some interesting things like:</p>
<pre>
ghci> let doubleAndAdd5 = (+5) . (*2)
ghci> doubleAndAdd5 20
45
ghci> :m +Data.List
ghci> let sumColumns = map sum . transpose
ghci> sumColumns [[1,2,3],[4,5,6],[7,8,9]]
[12,15,18]
</pre>
<p>Very handy indeed. While handy, it doesn't necessarily allow us to do everything we might want to do. One example is handling cases where we want to compose a function where the right-hand function takes two arguments instead of one.</p>
<p>So if we wanted to create a function that would take two values, add them together and double the result, all while using Point-Free style, we'd like to do something like this:</p>
<pre>
ghci> let addAndDouble = (*2) . (+)

<interactive>:1:20:
    No instance for (Num (a -> a))
      arising from a use of `*' at <interactive>:1:20-21
    Possible fix: add an instance declaration for (Num (a -> a))
    In the first argument of `(.)', namely `(* 2)'
    In the expression: (* 2) . (+)
    In the definition of `addAndDouble': addAndDouble = (* 2) . (+)
ghci>
</pre>
<p>As you can see, ghci doesn't like it. And rightly so! This is because the composition operator's signature is:</p>

<div class="wp_syntax"><div class="code"><pre class="haskell" style="font-family:monospace;"><span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">.</span><span style="color: green;">&#41;</span> <span style="color: #339933; font-weight: bold;">::</span> <span style="color: green;">&#40;</span>b <span style="color: #339933; font-weight: bold;">-&gt;</span> c<span style="color: green;">&#41;</span> <span style="color: #339933; font-weight: bold;">-&gt;</span> <span style="color: green;">&#40;</span>a <span style="color: #339933; font-weight: bold;">-&gt;</span> b<span style="color: green;">&#41;</span> <span style="color: #339933; font-weight: bold;">-&gt;</span> a <span style="color: #339933; font-weight: bold;">-&gt;</span> c</pre></div></div>

<p>That is:</p>
<ol>
<li>It takes an argument which is a function which takes a value of type <em>b</em> which returns a value of type <em>c</em></li>
<li>It takes a function which takes a value of type <em>a</em> which returns returns a value of type <em>b</em></li>
<li>It returns a new function which takes a value of type <em>a</em> and returns a value of type <em>c</em></li>
</ol>
<p>This doesn't work in our case, as we want our right-hand function to take two arguments. That is, we want a type signature that looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="haskell" style="font-family:monospace;">foo <span style="color: #339933; font-weight: bold;">::</span> <span style="color: green;">&#40;</span>b <span style="color: #339933; font-weight: bold;">-&gt;</span> c<span style="color: green;">&#41;</span> <span style="color: #339933; font-weight: bold;">-&gt;</span> <span style="color: green;">&#40;</span>a <span style="color: #339933; font-weight: bold;">-&gt;</span> a1 <span style="color: #339933; font-weight: bold;">-&gt;</span> b<span style="color: green;">&#41;</span> <span style="color: #339933; font-weight: bold;">-&gt;</span> a <span style="color: #339933; font-weight: bold;">-&gt;</span> a1 <span style="color: #339933; font-weight: bold;">-&gt;</span> c</pre></div></div>

<p>So everywhere we had <em>(a -> b)</em>, what we really want is <em>(a -> a1 -> b)</em>. Given that we don't have an operator that does that for us, let's define one. We'll start with the definition of the (.) operator and work towards a function that does what we need.</p>

<div class="wp_syntax"><div class="code"><pre class="haskell" style="font-family:monospace;"><span style="color: #5d478b; font-style: italic;">-- here is the composition operator again</span>
<span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">.</span><span style="color: green;">&#41;</span> f g x <span style="color: #339933; font-weight: bold;">=</span> f <span style="color: green;">&#40;</span>g x<span style="color: green;">&#41;</span>
<span style="color: #5d478b; font-style: italic;">-- here's our new operator's definition</span>
<span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">.^</span><span style="color: green;">&#41;</span> f g x y <span style="color: #339933; font-weight: bold;">=</span> f <span style="color: green;">&#40;</span>g x y<span style="color: green;">&#41;</span></pre></div></div>

<p>Simple! Let's see what ghci says about it:</p>
<pre>
ghci> let (.^) f g x y = f (g x y)
ghci> :t (.^)
a :: (t2 -> t3) -> (t -> t1 -> t2) -> t -> t1 -> t3
</pre>
<p>Looks good! This is exactly what we need. Now that we have a working function, let's aim to write this in Point-Free style. We do this by breaking down the function slowly and eliminating arguments by moving them to the far right hand side of the function definition.</p>
<p>The first argument to get rid of is 'y', as this is the last argument passed in:</p>

<div class="wp_syntax"><div class="code"><pre class="haskell" style="font-family:monospace;"><span style="color: #5d478b; font-style: italic;">-- start by moving y to the right</span>
<span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">.^</span><span style="color: green;">&#41;</span> f g x y <span style="color: #339933; font-weight: bold;">=</span> f <span style="color: green;">&#40;</span>g x y<span style="color: green;">&#41;</span>
<span style="color: #5d478b; font-style: italic;">-- becomes</span>
<span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">.^</span><span style="color: green;">&#41;</span> f g x y <span style="color: #339933; font-weight: bold;">=</span> f <span style="color: #339933; font-weight: bold;">.</span> <span style="color: green;">&#40;</span>g x<span style="color: green;">&#41;</span> <span style="color: #339933; font-weight: bold;">$</span> y</pre></div></div>

<p>These are functionally equivalent, and now that 'y' is out on it's own, we can drop it from our function definition:</p>
<pre>ghci> let (.^) f g x = f . (g x)
ghci> :t (.^)
(.^) :: (b -> c) -> (t -> a -> b) -> t -> a -> c
ghci>
</pre>
<p>Excellent, we're a step closer. Now we need to do the same with 'x'. This takes a little more fiddling:</p>

<div class="wp_syntax"><div class="code"><pre class="haskell" style="font-family:monospace;"><span style="color: #5d478b; font-style: italic;">-- we need to take the original definition</span>
<span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">.^</span><span style="color: green;">&#41;</span> f g x <span style="color: #339933; font-weight: bold;">=</span> f <span style="color: #339933; font-weight: bold;">.</span> <span style="color: green;">&#40;</span>g x<span style="color: green;">&#41;</span>
<span style="color: #5d478b; font-style: italic;">-- and change it so that it uses prefix notation instead of infix</span>
<span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">.^</span><span style="color: green;">&#41;</span> f g x <span style="color: #339933; font-weight: bold;">=</span> <span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">.</span><span style="color: green;">&#41;</span> f <span style="color: green;">&#40;</span>g x<span style="color: green;">&#41;</span>
<span style="color: #5d478b; font-style: italic;">-- which is the same as</span>
<span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">.^</span><span style="color: green;">&#41;</span> f g x <span style="color: #339933; font-weight: bold;">=</span> <span style="color: green;">&#40;</span><span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">.</span><span style="color: green;">&#41;</span> f<span style="color: green;">&#41;</span> <span style="color: green;">&#40;</span>g x<span style="color: green;">&#41;</span>
<span style="color: #5d478b; font-style: italic;">-- what we're doing is calling g with x and applying the result to f</span>
<span style="color: #5d478b; font-style: italic;">-- and hence we can compose the composition of f with the call to g</span>
<span style="color: #5d478b; font-style: italic;">-- giving us the following</span>
<span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">.^</span><span style="color: green;">&#41;</span> f g x <span style="color: #339933; font-weight: bold;">=</span> <span style="color: green;">&#40;</span><span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">.</span><span style="color: green;">&#41;</span> f<span style="color: green;">&#41;</span> <span style="color: #339933; font-weight: bold;">.</span> g <span style="color: #339933; font-weight: bold;">$</span> x
<span style="color: #5d478b; font-style: italic;">-- finally leaving us with</span>
<span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">.^</span><span style="color: green;">&#41;</span> f g <span style="color: #339933; font-weight: bold;">=</span> <span style="color: green;">&#40;</span><span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">.</span><span style="color: green;">&#41;</span> f<span style="color: green;">&#41;</span> <span style="color: #339933; font-weight: bold;">.</span> g</pre></div></div>

<p>Phew <img src='http://buffered.io/wp-content/plugins/smilies-themer/Silk/emoticon_smile.png' alt=':)' class='wp-smiley' /> I hope you can see the progression. We've managed to move x out of the picture, so now we're down to a fairly crazy looking definition. Let's see what ghci has to say:</p>
<pre>ghci> let (.^) f g = ((.) f) . g
ghci> :t (.^)
(.^) :: (b -> c) -> (a1 -> a -> b) -> a1 -> a -> c</pre>
<p>So we've got rid of two variables, but there are still two more to go! Remember, 'f' and 'g' are still variables, they just carry functions. So let's get rid of 'g':</p>

<div class="wp_syntax"><div class="code"><pre class="haskell" style="font-family:monospace;"><span style="color: #5d478b; font-style: italic;">-- start with what we had before</span>
<span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">.^</span><span style="color: green;">&#41;</span> f g <span style="color: #339933; font-weight: bold;">=</span> <span style="color: green;">&#40;</span><span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">.</span><span style="color: green;">&#41;</span> f<span style="color: green;">&#41;</span> <span style="color: #339933; font-weight: bold;">.</span> g
<span style="color: #5d478b; font-style: italic;">-- change to prefix notation again</span>
<span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">.^</span><span style="color: green;">&#41;</span> f g <span style="color: #339933; font-weight: bold;">=</span> <span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">.</span><span style="color: green;">&#41;</span> <span style="color: green;">&#40;</span><span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">.</span><span style="color: green;">&#41;</span> f<span style="color: green;">&#41;</span> g
<span style="color: #5d478b; font-style: italic;">-- and drop g</span>
<span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">.^</span><span style="color: green;">&#41;</span> f <span style="color: #339933; font-weight: bold;">=</span> <span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">.</span><span style="color: green;">&#41;</span> <span style="color: green;">&#40;</span><span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">.</span><span style="color: green;">&#41;</span> f<span style="color: green;">&#41;</span></pre></div></div>

<p>This is looking rather crazy <img src='http://buffered.io/wp-content/plugins/smilies-themer/Silk/emoticon_smile.png' alt=':)' class='wp-smiley' /> Again, let's make sure we haven't done anything stupid:</p>
<pre>ghci> let (.^) f = (.) ((.) f)
ghci> :t (.^)
(.^) :: (b -> c) -> (a1 -> a -> b) -> a1 -> a -> c</pre>
<p>Excellent. We've still got what we need. One more point needs to be dropped, so let's get rid of 'f':</p>

<div class="wp_syntax"><div class="code"><pre class="haskell" style="font-family:monospace;"><span style="color: #5d478b; font-style: italic;">-- start with what we had before</span>
<span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">.^</span><span style="color: green;">&#41;</span> f <span style="color: #339933; font-weight: bold;">=</span> <span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">.</span><span style="color: green;">&#41;</span> <span style="color: green;">&#40;</span><span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">.</span><span style="color: green;">&#41;</span> f<span style="color: green;">&#41;</span>
<span style="color: #5d478b; font-style: italic;">-- which means that we're composing a composition with a</span>
<span style="color: #5d478b; font-style: italic;">-- function composed of f and something else</span>
<span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">.^</span><span style="color: green;">&#41;</span> f <span style="color: #339933; font-weight: bold;">=</span> <span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">.</span><span style="color: green;">&#41;</span> <span style="color: #339933; font-weight: bold;">.</span> <span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">.</span><span style="color: green;">&#41;</span> <span style="color: #339933; font-weight: bold;">$</span> f
<span style="color: #5d478b; font-style: italic;">-- and we finally drop f</span>
<span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">.^</span><span style="color: green;">&#41;</span> <span style="color: #339933; font-weight: bold;">=</span> <span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">.</span><span style="color: green;">&#41;</span> <span style="color: #339933; font-weight: bold;">.</span> <span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">.</span><span style="color: green;">&#41;</span></pre></div></div>

<p>Isn't that just crazy! Let's again check ghci:</p>
<pre>ghci> let (.^) = (.) . (.)
ghci> :t (.^)
(.^) :: (b -> c) -> (a1 -> a -> b) -> a1 -> a -> c</pre>
<p>So there we have it, our operator completely in Point-Free style.</p>
<p>This is where the penny dropped for me. The whole exercise of moving through to Point-Free made me really understand what it was I was doing in the first place. The final definition makes it very clear. We're composing two separate compositions.<br />
Let's see if our function behaves itself using the example we listed above.</p>
<pre>
ghci> let addAndDouble = (*2) .^ (+)
ghci> :t addAndDouble
addAndDouble :: Integer -> Integer -> Integer
ghci> addAndDouble 10 15
50
ghci> addAndDouble 21 3
48
</pre>
<p>It does exactly what we need it too.</p>
<h3>Conclusion</h3>
<p>To sum up, Point-Free helps you tidy your code into more concise implementations which tend to aid you in understanding what it is you are trying to do. I feel it really helps you focus on what you're doing as opposed to what you're doing it to. It's down to you to determine whether you feel this is a good thing or not!</p>
<p>It is ultimately down to the developer to dictate when it should be used. There are definitely cases where the resulting function might not actually help in making things clearer. But on the whole, Point-Free style seems to help me understand what it is I'm doing (or, arguably, not doing).</p>
<p>Of course, you could just get sick and tired of trying to come up with variable names, in which case Point-Free is the bomb <img src='http://buffered.io/wp-content/plugins/smilies-themer/Silk/emoticon_smile.png' alt=':)' class='wp-smiley' /> </p>
<p>Feedback of any kind is always welcome. Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://buffered.io/2009/06/27/point-free-style-what-is-it-good-for/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>Data Crunching in Haskell</title>
		<link>http://buffered.io/2009/06/25/data-crunching-in-haskell/</link>
		<comments>http://buffered.io/2009/06/25/data-crunching-in-haskell/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 14:00:44 +0000</pubDate>
		<dc:creator>OJ</dc:creator>
				<category><![CDATA[Algorithms]]></category>
		<category><![CDATA[Functional Programming]]></category>
		<category><![CDATA[Haskell]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://buffered.io/?p=719</guid>
		<description><![CDATA[A few days ago I was having a chat to a friend of mine about a little data parsing problem. He had the need to parse a multi-dimensional array to pull out some values. That array was guaranteed to be square, but not necessarily in contiguous memory. He needed to parse each "column" of the [...]]]></description>
			<content:encoded><![CDATA[<p>A few days ago I was having a chat to a <a href="http://shiftperception.com/blog" title="Shifty">friend of mine</a> about a little data parsing problem. He had the need to parse a multi-dimensional array to pull out some values. That array was guaranteed to be square, but not necessarily in contiguous memory. He needed to parse each "column" of the array, calculate a total, and then determine the biggest and smallest of those totals.</p>
<p>A sample of the data might look something like this:</p>
<pre>
data = ({150,200,45,57,95,2,45,32,15,10,5,2,2,4},
         12,20,45,37,10,5,2,2,10,95,2,45,32,7},
         32,15,10,5,2,23,24,15,20,45,57,95,0,45})
</pre>
<p>So the first step would be to add 150, 12 and 32 and store the value. Then 200, 20 and 15, and store the value. Do this for all of the columns, then get a maximum and a minimum. </p>
<p>This little algorithm was going to be part of his project, and hence needed to be implemented in <a href="http://www.adobe.com/devnet/actionscript/articles/actionscript3_overview.html" title="ActionScript 3.0">AS3</a>. So I picked his brains about the AS3 syntax, because I have absolutely no clue given that I've never worked with any version of ActionScript in the past.</p>
<p>Together, we came up with the following solution:</p>
<pre>var columnTotal:Number;
var biggest:Number;
var smallest:Number;
biggest = smallest = sum(vData, 0);

for(var i = 1; i < _scope.period_mcs.length; ++i)
{
  columnTotal = sum(vData, i);
  biggest = Math.max(biggest, columnTotal);
  smallest = Math.min(smallest, columnTotal);
}

// helper function
function sum(var data:Array, var index:Integer):Number
{
  var total:Number = 0;
  for(int i = 0; i < data.length; ++i)
  {
    total += data[i][index];
  }
  return total;
}</pre>
<p>Does it work? Yes, it sure does. Is it optimal? Yes, and no <img src='http://buffered.io/wp-content/plugins/smilies-themer/Silk/emoticon_smile.png' alt=':)' class='wp-smiley' /> I was lazy and used the Math.max and Math.min functions instead of doing the obvious...</p>
<pre>
if(biggest < columnTotal) biggest = columnTotal;
</pre>
<p>So if we did that, to reduce the need for function calls and unnecessary assignments, we end up with this:</p>
<pre>var columnTotal:Number;
var biggest:Number;
var smallest:Number;
biggest = smallest = sum(vData, 0);

for(var i = 1; i < _scope.period_mcs.length; ++i)
{
  columnTotal = sum(vData, i);
  if(biggest < columnTotal)
  {
    biggest = columnTotal;
  }
  else if(smallest > columnTotal)
  {
    smallest = columnTotal;
  }
}

// helper function
function sum(var data:Array, var index:Integer):Number
{
  var total:Number = 0;
  for(int i = 0; i < data.length; ++i)
  {
    total += data[i][index];
  }
  return total;
}</pre>
<p>I can't see many ways to improve on this without going overboard with optimisation. Any AS3 guru's are more than welcome to prove me wrong!</p>
<p>So after thinking about this in an imperative language, I couldn't help but have a look at what the functional version might look like. Of course, my current chosen Functional toy is <a href="http://haskell.org/" title="Haskell">Haskell</a> and so I fired up <a href="http://vim.org/" title="VIM">VIM</a> and <a href="http://www.haskell.org/ghc/" title="GHC">GHCI</a> and had a bit of a play.</p>
<p>First, I put the data into Haskell's list format:</p>

<div class="wp_syntax"><div class="code"><pre class="haskell" style="font-family:monospace;">vals <span style="color: #339933; font-weight: bold;">=</span> <span style="color: green;">&#91;</span><span style="color: green;">&#91;</span><span style="color: red;">150</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">200</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">45</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">57</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">95</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">2</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">45</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">32</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">15</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">10</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">5</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">2</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">2</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">4</span><span style="color: green;">&#93;</span><span style="color: #339933; font-weight: bold;">,</span>
        <span style="color: green;">&#91;</span><span style="color: red;">12</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">20</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">45</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">37</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">10</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">5</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">2</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">2</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">10</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">95</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">2</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">45</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">32</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">7</span><span style="color: green;">&#93;</span><span style="color: #339933; font-weight: bold;">,</span>
        <span style="color: green;">&#91;</span><span style="color: red;">32</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">15</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">10</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">5</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">2</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">23</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">24</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">15</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">20</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">45</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">57</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">95</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">0</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">45</span><span style="color: green;">&#93;</span><span style="color: green;">&#93;</span></pre></div></div>

<p>That was easy enough. The next step was to break the problem down so that I could use some of the built in functions of Haskell's <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html" title="Prelude">Prelude</a> libraries. My thought processes were:</p>
<ol>
<li>Summing the column of the array could be done using <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:sum" title="sum">sum</a>, but I'd need to change the list so that rows become columns, and vice-versa.</li>
<li>To switch rows and columns, I could use the <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Data-List.html#v:transpose" title="Data.List.transpose">transpose</a> function.</li>
<li>Then all I'd need to do is use <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:maximum" title="maximum">maximum</a> and <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:minimum" title="minimum">minimum</a> to get the right values out.</li>
</ol>
<p>Being a bit of a primitive Haskeller, my first pass was something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="haskell" style="font-family:monospace;">extremes n <span style="color: #339933; font-weight: bold;">=</span> <span style="color: green;">&#40;</span>b<span style="color: #339933; font-weight: bold;">,</span> s<span style="color: green;">&#41;</span>
  <span style="color: #06c; font-weight: bold;">where</span>
    l <span style="color: #339933; font-weight: bold;">=</span> <span style="font-weight: bold;">map</span> <span style="font-weight: bold;">sum</span> <span style="color: #339933; font-weight: bold;">$</span> transpose n
    b <span style="color: #339933; font-weight: bold;">=</span> <span style="font-weight: bold;">maximum</span> l
    s <span style="color: #339933; font-weight: bold;">=</span> <span style="font-weight: bold;">minimum</span> l</pre></div></div>

<p>The function <em>extremes</em> is the function which takes the data (list of lists) and spits out a tuple of <em>(max, min)</em>.</p>
<p>Before the end of the conversation with my designer colleague in arms, I pinged him my version of the solution in Haskell and needless to say he was a little surprised as how concise it was. I was sure to point out that there is no doubt a better way of representing this solution with regards to speed and conciseness.</p>
<p>The first thing that I thought could be improved would be using a custom <a href="http://www.haskell.org/haskellwiki/Fold" title="Fold">fold</a> to get the max and min while parsing the transposed list. This would allow us to calculate the values in a single pass and hence be a little better with regards to performance. That would obviously sacrifice a little bit of the conciseness we're looking for.</p>
<p>When the conversation ended, I jumped onto IRC and spoke to some more seasoned Haskellers. The first suggested improvement that popped out of that chat was to use <a href="http://www.haskell.org/arrows/" title="Arrows">arrows</a> to remove the need for the where clause. That solution looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="haskell" style="font-family:monospace;">extremes <span style="color: #339933; font-weight: bold;">=</span> <span style="color: green;">&#40;</span><span style="font-weight: bold;">maximum</span> <span style="color: #339933; font-weight: bold;">&amp;&amp;</span>&amp; <span style="font-weight: bold;">minimum</span><span style="color: green;">&#41;</span> <span style="color: #339933; font-weight: bold;">.</span> <span style="font-weight: bold;">map</span> <span style="font-weight: bold;">sum</span> <span style="color: #339933; font-weight: bold;">.</span> transpose</pre></div></div>

<p>Nifty <img src='http://buffered.io/wp-content/plugins/smilies-themer/Silk/emoticon_smile.png' alt=':)' class='wp-smiley' /> Of all the other options, this proved to be the most readable and concise, though not the best performing.</p>
<p>The next most notable solution included the fold which calculated the min and max in a single parse, not a double parse:</p>

<div class="wp_syntax"><div class="code"><pre class="haskell" style="font-family:monospace;">extremes <span style="color: #339933; font-weight: bold;">=</span> <span style="font-weight: bold;">foldl1</span> <span style="color: green;">&#40;</span>\<span style="color: green;">&#40;</span>a<span style="color: #339933; font-weight: bold;">,</span> b<span style="color: green;">&#41;</span> <span style="color: #339933; font-weight: bold;">-&gt;</span> <span style="font-weight: bold;">max</span> a <span style="color: #339933; font-weight: bold;">***</span> <span style="font-weight: bold;">min</span> b<span style="color: green;">&#41;</span> <span style="color: #339933; font-weight: bold;">.</span> join <span style="font-weight: bold;">zip</span> <span style="color: #339933; font-weight: bold;">.</span> <span style="font-weight: bold;">map</span> <span style="font-weight: bold;">sum</span> <span style="color: #339933; font-weight: bold;">.</span> transpose</pre></div></div>

<p>Folds really are fantastic aren't they. Again we're using arrows here to do a bit of heavy lifting and that keeps things looking a little nicer.</p>
<p>So after this little session, my designer friend was aware of how easy it can be to crunch certain types of data using a functional language, like Haskell. It made me think again about how it'd be nice to just be able to plug in whichever language we wanted whenever we felt it would do the job better than whatever the current tool is.</p>
<p>So how would you improve it? <img src='http://buffered.io/wp-content/plugins/smilies-themer/Silk/emoticon_smile.png' alt=':)' class='wp-smiley' /> </p>
<p>
<!-- Begin Google Adsense code -->
<p><center>
<script type="text/javascript"><!--
google_ad_client = "pub-5662448744756930";
/* 468x60, created 2/11/09 */
google_ad_slot = "8047929723";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></center></p>
<!-- End Google Adsense code -->
</p>
]]></content:encoded>
			<wfw:commentRss>http://buffered.io/2009/06/25/data-crunching-in-haskell/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
