<?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>dwink &#187; Braindump</title>
	<atom:link href="http://www.dwink.net/category/braindump/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dwink.net</link>
	<description>i owned a company and all i got was this stupid blog</description>
	<lastBuildDate>Mon, 06 Sep 2010 14:29:49 +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>Everything I Ever Needed To Know I Learned From Watching Kung Fu</title>
		<link>http://www.dwink.net/2009/09/05/everything-i-ever-needed-to-know-i-learned-from-watching-kung-fu/</link>
		<comments>http://www.dwink.net/2009/09/05/everything-i-ever-needed-to-know-i-learned-from-watching-kung-fu/#comments</comments>
		<pubDate>Sun, 06 Sep 2009 04:36:59 +0000</pubDate>
		<dc:creator>d.w.</dc:creator>
				<category><![CDATA[Braindump]]></category>
		<category><![CDATA[The Daver Makes Nerds Look Cool]]></category>
		<category><![CDATA[fibonacci]]></category>
		<category><![CDATA[haskell]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[scheme]]></category>

		<guid isPermaLink="false">http://www.dwink.net/?p=94</guid>
		<description><![CDATA[...except functional programming. That I learned in college. My professor at the time was a young dude who had the idea that the best way to learn about programming language design &#38; construction was by learning five languages in one semester. Some were simple to wrap our C++-and-Java-bred minds around, like C, and some were [...]]]></description>
			<content:encoded><![CDATA[<p>...except functional programming. That I learned in college.</p>
<p>My professor at the time was a young dude who had the idea that the best way to learn about programming language design &amp; construction was by learning five languages in one semester. Some were simple to wrap our C++-and-Java-bred minds around, like C, and some were painful to paradigm-shift into, like Prolog. But the first language, and the one that truly gave me insight into what makes a programming language a useful tool, was <a href="http://groups.csail.mit.edu/mac/projects/scheme/" target="_blank">Scheme</a>.</p>
<p>Scheme, the simple dialect of Lisp, the parenthesis-heavy language with terms like "car" and "cdr". Where tail-recursion is the paradigm of choice and the iterative, C-style "do-this-then-that" habits had to be broken before we could truly begin to program elegantly. I spent hours and hours writing tic-tac-toe in Scheme; I think the most important thing I learned was to avoid assuming that a particular convention works well in all environments.</p>
<p>To give you an idea, here's a lovely Fibonacci sequence generator in Scheme: (for the non-CS/math grads, the Fibonacci sequence is a pattern of numbers: 0 1 1 2 3 5 8 13 21 34 ... or, each number equals the sum of the two previous numbers ... which makes for a great little sample program )</p>

<div class="wp_syntax"><div class="code"><pre class="scheme" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> fib
  <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">lambda</span> <span style="color: #66cc66;">&#40;</span>n<span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">cond</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">=</span> n <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
          <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">=</span> n <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>
          <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">+</span> <span style="color: #66cc66;">&#40;</span>fib <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">-</span> n <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
                   <span style="color: #66cc66;">&#40;</span>fib <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">-</span> n <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Lately, as a mental exercise (read: to procrastinate on some of the less-interesting paperwork I was supposed to be doing ), I started to play around with <a href="http://www.haskell.org/" target="_blank">Haskell</a>. I'm having a ball, mostly because Haskell is so much more strict about eliminating side effects, which means that the language directly supports designs which are compositions of pure functions. Why does that matter? Well, if you can't mess around with memory or resources outside of your function, then you can't break things outside of your function either <img src='http://www.dwink.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .</p>
<p>Fibonacci in Haskell:</p>

<div class="wp_syntax"><div class="code"><pre class="haskell" style="font-family:monospace;">fib x <span style="color: #339933; font-weight: bold;">=</span>
    <span style="color: #06c; font-weight: bold;">if</span> x <span style="color: #339933; font-weight: bold;">==</span> <span style="color: red;">0</span>
        <span style="color: #06c; font-weight: bold;">then</span> <span style="color: red;">0</span>
        <span style="color: #06c; font-weight: bold;">else</span> <span style="color: #06c; font-weight: bold;">if</span> x <span style="color: #339933; font-weight: bold;">==</span> <span style="color: red;">1</span>
            <span style="color: #06c; font-weight: bold;">then</span> <span style="color: red;">1</span>
            <span style="color: #06c; font-weight: bold;">else</span> fib <span style="color: green;">&#40;</span>x <span style="color: #339933; font-weight: bold;">-</span><span style="color: red;">1</span><span style="color: green;">&#41;</span> <span style="color: #339933; font-weight: bold;">+</span> fib <span style="color: green;">&#40;</span>x<span style="color: #339933; font-weight: bold;">-</span><span style="color: red;">2</span><span style="color: green;">&#41;</span></pre></div></div>

<p>Why do I like this better? Well, aside from the fact that there's no stack notation ( operator, operand, operand...), so I can let my brain think in a more human way, it does away with all those blasted parens.</p>
<p>Of course, since this is about hour two with Haskell, I can't quite comment on whether I like it as a whole, but I can certainly see how programs developed with it are more easily proven correct; an entire class of possible problems is eliminated by eliminating side effects.</p>
<p>Anyhow, if anyone else is interested in learning Haskell too, and wants to put some code together on a side project ( purely for the fun of it ), let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dwink.net/2009/09/05/everything-i-ever-needed-to-know-i-learned-from-watching-kung-fu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Random Notes on Computer Games</title>
		<link>http://www.dwink.net/2009/06/16/random-notes-on-computer-games/</link>
		<comments>http://www.dwink.net/2009/06/16/random-notes-on-computer-games/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 13:37:44 +0000</pubDate>
		<dc:creator>d.w.</dc:creator>
				<category><![CDATA[Braindump]]></category>

		<guid isPermaLink="false">http://www.dwink.net/?p=84</guid>
		<description><![CDATA[I've just played through the old Hitchhiker's Guide to the Galaxy text adventure game with Frotz on my iPhone. With a puff of nostalgia, I was reminded of being maybe 10 years old, sitting in the basement with our Apple //c, fishing through the cardboard box of 5.25" floppy disks and pulling out a host [...]]]></description>
			<content:encoded><![CDATA[<p>I've just played through the old Hitchhiker's Guide to the Galaxy text adventure game with Frotz on my iPhone. With a puff of nostalgia, I was reminded of being maybe 10 years old, sitting in the basement with our Apple //c, fishing through the cardboard box of 5.25" floppy disks and pulling out a host of classics. Karateka, the cheerfully awful Castle Smurfenstein, Dino Eggs, and finally, the Hitchhiker's Guide game.</p>
<p>Now THIS was something cool: the game opens with the computer giving you the introdiction to a story. Then, you just tell the computer what to do in more-or-less plain English, and it'd go ahead and do it ( or, sometimes, refuse hilariously) in the story world, telling you what changed. It was so simple -- just text on the screen, a virtual 'intelligence' and a virtual world to explore.</p>
<p>Being a kid, I pictured myself an ellite hacker-type, typing into the night, peeling away the layers of puzzles to see the core artificial intelligence living in it's artificial world. The glow of just text on the screen made it easy to pretend -- I already was a bookworm, so I was used to imagining my stories anyhow. This took it to another level. It was my story!</p>
<p>Soon, of course, the interactions get silly. I'd try random things ( KICK THE DOG, EAT MUSHROOM ) just to see what the game would say. Often, you'd just get the standard "I couldn't do that! Fido is your best friend!" or "I don't know how to eat that.", but once in a while you'd get a great response: "you chew up the mushroom; it tastes like gooey dirt. Slowly, the colors drain from the walls and the dog begins to quote Glengarry Glen Ross. Funny; he never liked Mamet before."</p>
<p>After spending hours in front of these games, getting horribly stuck in all of them ( Adults need hints for these games; I was 7 or 8 ), what else could I do? I started writing my own. My friend Brian and I started crafting a brilliant piece of interactive fiction called "The Good Day". Brilliant, I tell you! It had three whole rooms! It was written in Applesoft BASIC! You could fart and belch, you could kick stuff, you could use two-word commands! It was very nearly a work of art, ready for publishing... Except that it took about ten minutes to get through all the fart jokes and then ended abruptly, and had no real plot, and...</p>
<p>But it was ours.</p>
<p>So nowadays, that GOTO-laden mess of code seems quaint to me as I write software that processes millions of transactions, but I miss the unbridled enthusiasm for hilarity we had. So in my next program, I think an Easter egg needs to be hidden: from time to time, in the midst of the millions of operations in the code, my fancy processing code will have gas, and leave an "oops, I farted" in the logfile.</p>
<p>Because no, I still haven't grown out of fart jokes. And admit it, neither have you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dwink.net/2009/06/16/random-notes-on-computer-games/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
