<?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>while coding &#187; programming languages</title>
	<atom:link href="http://www.youell.com/matt/writing/?cat=9&#038;feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.youell.com/matt/writing</link>
	<description>simplify</description>
	<lastBuildDate>Wed, 31 Oct 2018 04:08:22 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>A Data Structure Runs Through It</title>
		<link>http://www.youell.com/matt/writing/?p=769</link>
		<comments>http://www.youell.com/matt/writing/?p=769#comments</comments>
		<pubDate>Wed, 01 Dec 2010 22:16:58 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Road To Wheeler]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[programming languages]]></category>

		<guid isPermaLink="false">http://www.youell.com/matt/writing/?p=769</guid>
		<description><![CDATA[I&#8217;m surprised to be developing a programming language. I didn&#8217;t know I had a language in me until a few years ago. I always considered new languages kind of a waste. Most of the cool tricks seem to be known. No reason they can&#8217;t be added to existing languages, right?
The past few years of wide-ranging [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m surprised to be developing a programming language. I didn&#8217;t know I had a language in me until a few years ago. I always considered new languages kind of a waste. Most of the cool tricks seem to be known. No reason they can&#8217;t be added to existing languages, right?</p>
<p>The past few years of wide-ranging language interest have cast doubt on that perspective. Still, one theme that I can&#8217;t shake is that you should be able to model new features in an existing language. It might be awkward, but it should still be possible. (Especially if you&#8217;re going to implement the language!)</p>
<p>In that spirit, I&#8217;ve tried to express one of the core ideas in Wheeler with a library for Python called <a href="https://github.com/built/AssociativeTools">AssociativeTools</a>. The star of the show is the Workspace class, which represents a data structure I call an Associative Network.</p>
<p>The word &#8220;network&#8221; is overloaded. Most often it is used to refer to computer networks. Here, I&#8217;m referring to a <a href="http://en.wikipedia.org/wiki/Network_model_(database)">network or web of data</a>. Think of a big pool of data in which nodes can be arranged into graphs of your choosing.</p>
<p>The Workspace lets you relate items (anything that is hashable in Python) to one another. Mostly I&#8217;m using strings and numbers. You relate items to build graphs so that later you can come back and fetch those graphs with partial information. It&#8217;s a lot like querying a database. It&#8217;s more like querying a search engine. Look:</p>
<p><code language="python"><br />
s = Workspace()<br />
s.associate("foo", "bar", "baz")<br />
# Later in the code...<br />
print(s.comprehend("foo"))<br />
</code></p>
<p>Outputs:</p>
<pre>set(['bar', 'baz'])</pre>
<p>Btw, the naming for all of this (AssociativeNetwork, associate, comprehend) is all flexible. Suggestions are welcome.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.youell.com/matt/writing/?feed=rss2&amp;p=769</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Introduction To Wheeler, Part 3: Transitions and Mutual Dispatch</title>
		<link>http://www.youell.com/matt/writing/?p=665</link>
		<comments>http://www.youell.com/matt/writing/?p=665#comments</comments>
		<pubDate>Thu, 22 Jul 2010 00:59:10 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Road To Wheeler]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[programming languages]]></category>
		<category><![CDATA[wheeler]]></category>

		<guid isPermaLink="false">http://www.youell.com/matt/writing/?p=665</guid>
		<description><![CDATA[Hey, quick, watch this video before you read any further. It&#8217;s under 2 minutes long and it is *fascinating*.

That video is about how cell membranes work. Did you notice how proteins, enzymes, etc. can only pass through the cell membrane if they are the right shape (and flavor)? That&#8217;s how values trigger transitions in Wheeler.
Transitions
If [...]]]></description>
			<content:encoded><![CDATA[<p>Hey, quick, watch this video before you read any further. It&#8217;s under 2 minutes long and it is *fascinating*.</p>
<p><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/owEgqrq51zY&amp;hl=en_US&amp;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/owEgqrq51zY&amp;hl=en_US&amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></p>
<p>That video is about how cell membranes work. Did you notice how proteins, enzymes, etc. can only pass through the cell membrane if they are the right shape (and flavor)? That&#8217;s how values trigger transitions in Wheeler.</p>
<h3>Transitions</h3>
<p>If categories are the most minimal representation of state, then transitions are the most minimal representation of action. Transitions are how computation happens in Wheeler. After all, organizing data is only half the battle with programming. Once you have the data in the form you want, you have to actually <em>do something</em>.</p>
<p>You can think of transitions as being very much like an event handler. You define a transition to trigger when an interaction between one or more categories happens.</p>
<p>Since Wheeler is still a work in progress, transitions are not yet native. Instead, transitions are created in Python, the language Wheeler is built on.</p>
<p>Remember our Hello example?</p>
<p><img src="http://www.youell.com/matt/writing/wp-content/uploads/2010/07/hello_world_363x174.png" alt=""  style="float: none"/></p>
<p>Here&#8217;s the transition defined for it in Python:</p>
<pre class="syntax-highlight:php">
def printer(category):
	for item in category:
		print item.name[1:-1],
	print
	return []

ROOT.create(&#039;print&#039;).add_handler( STRING, printer )
</pre>
<p>(I&#8217;ve omitted some unimportant details for clarity.)</p>
<p>What you might be able to suss out here is that there is a ROOT category that all categories live within, and I&#8217;ve created a &#8220;print&#8221; category within that. In addition, I&#8217;ve added a transition (with add_handler) which knows to watch for interactions with items in the string category. If the transition finds an interaction that matches, it executes the printer() function, which simply calls Python&#8217;s &#8216;print&#8217; function.</p>
<h3>Mutual Dispatch</h3>
<p>When more than one transition is triggered by an expression, the transitions all execute AND &#8211; at least in concept &#8211; they all execute *at the same time*.</p>
<p>This is very much like the real world. If two objects collide you don&#8217;t say that one or the other of them collided first. The collision is mutual and simultaneous. In that same way, when categories interact, the interaction is mutual and simultaneous.</p>
<p>Here&#8217;s the final snippet of Wheeler for this introduction:</p>
<p><img src="http://www.youell.com/matt/writing/wp-content/uploads/2010/07/mutual_dispatch.png" alt=""  style="float: none"/></p>
<p>In case it&#8217;s not clear what is going on here, we have some numbers, which are in the category &#8216;number&#8217;, some text in the category &#8217;string&#8217;, and some other categories (&#8217;print&#8217;, &#8216;+&#8217;) which give it all meaning with transitions. One transition knows to add all of the numbers in the expression when the plus sign is present. Another transition knows to print all of the strings in the expression to stdout when the &#8216;print&#8217; category is present.</p>
<p>When presented with this jumble of categories, Wheeler figures out what to do based on the criteria of the transitions. This effectively creates a typed-dispatch mechanism. I call this simultaneous, polymorphic behavior &#8220;Mutual Dispatch&#8221;.</p>
<p>That sums up Wheeler as currently implemented. </p>
<p>There&#8217;s still a lot of work to be done. I&#8217;ve covered what Wheeler is currently capable of. There are other planned features that I didn&#8217;t cover and hope to implement soon. I will provide more info here as new features are added.</p>
<p>I hope you find it as oddly fascinating as I do! Feedback is not just requested, it is begged for. I also strongly encourage you to <a href="http://github.com/built/wheeler">grab the code</a>, play, and contribute.</p>
<p>(Thanks to Westside Programmers and #pdxfunc for letting me present on Wheeler a few times over the past year. Having the chance to present and receive feedback has firmed up the concepts in my mind and made them easier to distill into this introduction.)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.youell.com/matt/writing/?feed=rss2&amp;p=665</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Introduction To Wheeler, Part 2: Values &amp; Types</title>
		<link>http://www.youell.com/matt/writing/?p=663</link>
		<comments>http://www.youell.com/matt/writing/?p=663#comments</comments>
		<pubDate>Wed, 21 Jul 2010 23:57:31 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Road To Wheeler]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[programming languages]]></category>
		<category><![CDATA[wheeler]]></category>

		<guid isPermaLink="false">http://www.youell.com/matt/writing/?p=663</guid>
		<description><![CDATA[(Note: It may be helpful to read the posts I did on types several months ago.)
Someone recently asked me if Wheeler had types. My answer was &#8220;No. Uhhh&#8230; and yes.&#8221; What a terrible answer! I&#8217;ll try to do better in this post.
Wheeler has no explicit type system. You will never declare a value to be [...]]]></description>
			<content:encoded><![CDATA[<p>(Note: It may be helpful to read the <a href="http://www.youell.com/matt/writing/?p=601">posts I did on types</a> several months ago.)</p>
<p>Someone recently asked me if Wheeler had types. My answer was &#8220;No. Uhhh&#8230; and yes.&#8221; What a terrible answer! I&#8217;ll try to do better in this post.</p>
<p>Wheeler has no explicit type system. You will never declare a value to be of a certain type. You might, however, associate a value with a particular category through an interaction. In that way you&#8217;re establishing a relationship that will allow typing *behavior*.</p>
<h3>What is a value?</h3>
<p>Values are the imaginary, interstitial things floating between categories. When you establish a relationship between categories in Wheeler, you&#8217;re creating values.</p>
<h3>What is a type?</h3>
<p>I won&#8217;t attempt to answer this in general. I am not a type theorist. From the perspective of Wheeler we might say that a type is determined by a graph&#8217;s &#8220;shape&#8221; and &#8220;flavor&#8221;. Shape is the actual form of the graph we create in memory (tree, ring, object, etc.). Flavor is what specific categories are being connected by that graph.</p>
<h3>What the hell is the difference?</h3>
<p>Context. It&#8217;s all context. A value will trigger typing behavior when something matching that shape and flavor is being watched for. At that point it could be considered a type. The rest of the time, a value.</p>
<h3>Layering values into types</h3>
<p>Have you ever seen an artist paint a landscape? First they&#8217;ll paint the background&#8230; the sky, the horizon, the land. Then they start to layer on more and more detail. At what point does their work become a painting? Existential arguments aside, you might say that the work is a painting when it meets the criteria of the artist. Criteria will vary from artist to artist. Everyone has their own objectives, aesthetics, etc. In other words, everyone brings their own point of view or <em>context</em> to a situation. This idea is so fundamental in Wheeler that it is a core value of the language:</p>
<p><strong>Context Drives Behavior</strong></p>
<p>To help understand this, let&#8217;s look at a Venn diagram. (Venn diagrams are quite handy for discussing concepts in Wheeler.)</p>
<p><img style="float: none" src="http://www.youell.com/matt/writing/wp-content/uploads/2010/07/value_cars.png" alt="" /></p>
<p>Here you see we&#8217;ve got just a category, Cars. You could think of that as a type. Let&#8217;s pile on some more specifics:</p>
<p><img style="float: none" src="http://www.youell.com/matt/writing/wp-content/uploads/2010/07/value_cars_honda.png" alt="" /></p>
<p><img style="float: none" src="http://www.youell.com/matt/writing/wp-content/uploads/2010/07/value_cars_honda_element.png" alt="" /></p>
<p>Now we&#8217;ve got all cars that are Honda Elements. That&#8217;s more specific, but it&#8217;s still more like a type than anything.</p>
<p><img style="float: none" src="http://www.youell.com/matt/writing/wp-content/uploads/2010/07/value_cars_honda_element_vin.png" alt="" /></p>
<p>Ah, but now that we have a VIN, the unique Vehicle Identification Number. That&#8217;s so unique as to specify a particular vehicle. That seems more like a concrete value now. Yay.</p>
<p><img style="float: none" src="http://www.youell.com/matt/writing/wp-content/uploads/2010/07/value_cars_honda_element_vin_actual.png" alt="" /></p>
<p><a href="http://www.youell.com/matt/writing/?p=665">Next time</a> we&#8217;ll look at <em>Transitions</em> which allow computation in Wheeler. Then we&#8217;ll exercise our type and value scheme.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.youell.com/matt/writing/?feed=rss2&amp;p=663</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Introduction To Wheeler, Part 1: Categories &amp; Interactions</title>
		<link>http://www.youell.com/matt/writing/?p=659</link>
		<comments>http://www.youell.com/matt/writing/?p=659#comments</comments>
		<pubDate>Thu, 08 Jul 2010 16:07:39 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Road To Wheeler]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[programming languages]]></category>
		<category><![CDATA[wheeler]]></category>

		<guid isPermaLink="false">http://www.youell.com/matt/writing/?p=659</guid>
		<description><![CDATA[I started my &#8220;Road to Wheeler&#8221; series last year to introduce some of the ideas behind Wheeler, a new programming language I&#8217;ve been developing. Instead of continuing that discussion I&#8217;m going to explain through demonstration. This is the first in a series of posts that will introduce the basic ideas behind Wheeler.
(You can play along [...]]]></description>
			<content:encoded><![CDATA[<p>I started my &#8220;Road to Wheeler&#8221; series last year to introduce some of the ideas behind Wheeler, a new programming language I&#8217;ve been developing. Instead of continuing that discussion I&#8217;m going to explain through demonstration. This is the first in a series of posts that will introduce the basic ideas behind Wheeler.</p>
<p>(You can play along at home by grabbing <a href="http://github.com/built/wheeler">the latest code</a> and running the examples. You&#8217;ll need Python 2.5 and patience.)</p>
<p>First, let&#8217;s fire up &#8220;bigwheel&#8221;, the Wheeler interpreter:</p>
<p><img style="float: none" src="http://www.youell.com/matt/writing/wp-content/uploads/2010/07/bigwheel_349x150.png" alt="" /></p>
<p>Here is &#8220;Hello, world&#8221; in Wheeler:</p>
<p><img style="float: none" src="http://www.youell.com/matt/writing/wp-content/uploads/2010/07/hello_world_363x174.png" alt="" /></p>
<p>Wheeler is flexible though, so you could also say:</p>
<p><img style="float: none" src="http://www.youell.com/matt/writing/wp-content/uploads/2010/07/hello_world2_355x150.png" alt="" /></p>
<p>More on that later.</p>
<h3>Categories</h3>
<p>Wheeler is different from many languages you may be familiar with. All languages have abstractions. Some common examples are functions, lists, collections, stacks, pointers, and objects. In Wheeler, <strong>state</strong> is the fundamental abstraction.</p>
<p>State is represented by an abstraction called a Category. Categories are lightweight, atomic things. In Wheeler, <em>everything</em> is a category. Here are some sample categories:</p>
<ul>
<li>Fred</li>
<li>blue</li>
<li>5.3</li>
<li>&#8220;Hello, world!&#8221;</li>
<li>number</li>
<li>3/15/10</li>
<li>send</li>
<li>05:10:59</li>
<li>AM</li>
<li>PM</li>
<li>true</li>
<li>print</li>
</ul>
<p>Categories express boolean state. You&#8217;re either in a category or you&#8217;re not. Here&#8217;s an example:</p>
<p><img style="float: none" src="http://www.youell.com/matt/writing/wp-content/uploads/2010/07/apple_red.png" alt="" /></p>
<p>Do you see that? No? Good. What you do not see is &#8216;apple&#8217; being put into the &#8216;red&#8217; category. That is happening behind the scenes through an <em>interaction</em> between apple and red.</p>
<p>Categories aren&#8217;t containers, but from a practical standpoint they act like containers. This allows you to make statements about the world. We can pile some more attributes on &#8220;apple&#8221;:</p>
<p><img style="float: none" src="http://www.youell.com/matt/writing/wp-content/uploads/2010/07/apple_red2.png" alt="" /></p>
<h3>Interactions</h3>
<p>Interactions are expressions that combine categories to create new states. Our &#8220;Hello, world!&#8221; was an example of an interaction. Making our apple red was another interaction. Interaction is a mutual, simultaneous event where a connection (graph edge) is created between each item in the expression.</p>
<p>Wheeler has a &#8220;dump&#8221; command that will let you see (in GraphViz) the relationships you&#8217;ve created. Let&#8217;s dump &#8220;apple&#8221; and see the relationships:</p>
<p><img style="float: none" src="http://www.youell.com/matt/writing/wp-content/uploads/2010/07/apple_dump.png" alt="" /></p>
<p>And the relationships as diagrammed in GraphViz:</p>
<p><img style="float: none" src="http://www.youell.com/matt/writing/wp-content/uploads/2010/07/apple_graph.png" alt="" /></p>
<p>Here you can see that &#8220;apple&#8221; is related to &#8220;red&#8221;, &#8220;tasty&#8221;, and &#8220;sweet&#8221;. (You might notice that it is also related to &#8220;dump&#8221;, the category it interacted with to generate our diagram, and &#8220;metadata&#8221;, a built-in category.)</p>
<p>You can see that not only is &#8216;apple&#8217; connected to &#8216;red&#8217;, but &#8216;red&#8217; is also connected to &#8216;apple&#8217;. In Wheeler all relationships are bidirectional. This may seem odd if you&#8217;re used to typical hierarchical relationships in programming. Wheeler doesn&#8217;t think about the world that way. Wheeler has a few strongly-held beliefs, and one of these is:</p>
<p><strong>Hierarchy Is Bullshit</strong></p>
<p><a href="http://www.youell.com/matt/writing/?p=663">Next time</a> we&#8217;ll talk about composing categories into types.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.youell.com/matt/writing/?feed=rss2&amp;p=659</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Cat In the Hat</title>
		<link>http://www.youell.com/matt/writing/?p=563</link>
		<comments>http://www.youell.com/matt/writing/?p=563#comments</comments>
		<pubDate>Sat, 26 Sep 2009 19:33:10 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[How I Code]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[programming languages]]></category>

		<guid isPermaLink="false">http://www.youell.com/matt/writing/?p=563</guid>
		<description><![CDATA[I continue to be impressed by the flexibility of list comprehensions, especially in Python. The other day I discovered that I could handle a small but twisty problem quite simply, which I will now share in the style of Dr. Seuss:


[hat[cat] if cat in hat else cat for cat in cats] 

]]></description>
			<content:encoded><![CDATA[<p>I continue to be impressed by the flexibility of list comprehensions, especially in Python. The other day I discovered that I could handle a small but twisty problem quite simply, which I will now share in the style of Dr. Seuss:</p>
<pre class="syntax-highlight:python">

[hat[cat] if cat in hat else cat for cat in cats] 
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.youell.com/matt/writing/?feed=rss2&amp;p=563</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Metaprogramming and Hackitude</title>
		<link>http://www.youell.com/matt/writing/?p=418</link>
		<comments>http://www.youell.com/matt/writing/?p=418#comments</comments>
		<pubDate>Mon, 22 Jun 2009 21:23:49 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[conferences]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[programming languages]]></category>

		<guid isPermaLink="false">http://www.youell.com/matt/writing/?p=418</guid>
		<description><![CDATA[If you read about the disappointing results of my 30-in-30 project, you may have wondered what I was working on instead of my vaporous 30 releases. Aside from perfecting my tan and sculpting my rock-hard abs, for the past few weeks I&#8217;ve been working with @MarkusQ on a talk titled &#8220;Spindle, Mutilate, and Metaprogram: How [...]]]></description>
			<content:encoded><![CDATA[<p>If you read about the disappointing results of my 30-in-30 project, you may have wondered what I was working on instead of my vaporous 30 releases. Aside from perfecting my tan and sculpting my rock-hard abs, for the past few weeks I&#8217;ve been working with <a href="http://twitter.com/MarkusQ">@MarkusQ</a> on a talk titled &#8220;<a href="http://opensourcebridge.org/sessions/25">Spindle, Mutilate, and Metaprogram: How far can you push it before there be dragons?</a>&#8220;, which we presented last Wednesday at <a href="http://opensourcebridge.org/">Open Source Bridge</a>.</p>
<p>Giving the talk was a blast. There was a lot more prep to do than I expected, and we had so many ideas that only a fraction made it into the talk. That&#8217;s a little disappointing, but the audience was entertained and engaged and I think that&#8217;s what really matters.</p>
<p>One unexpected result of prepping for the talk is that my &#8220;hackitude&#8221; shot up tremendously. Our talk revolved around many code samples in several different languages, and we ended up using only a fraction of the code we created. So the bottom line is that we wrote a lot of code in a fairly short amount of time. Not only that, but the code really just flowed. It wasn&#8217;t effortless, but it was definitely satisfying and productive.</p>
<p>This is exactly the kind of increase in capability that I was aiming for with my 30-in-30 project. I think the difference here was that I was doing the code purely for the fun of it. A lot of our code examples were gags and language hacks that elicited both deep thought and chuckles from us as we worked on them. Having a collaborator was also a huge win. We sent a lot of code back and forth to each other over the past few weeks and that increased our velocity quite a bit.</p>
<p>A couple of people blogged about our talk <a href="http://www.baconandtech.com/2009/06/20/osbridge-recap/">here</a> and <a href="http://www.cuberick.com/2009/06/meta-programming-with-barf-bag.html">here</a>.</p>
<p>The <a href="http://github.com/MarkusQ/Jane-Kelly/tree/master">code</a> and <a href="http://youell.com/matt/osb09/dragons.odp">slides</a> are both available. </p>
<p>Audio was recorded from the talk (although we forgot to repeat questions and sometimes I was off-mike). When that&#8217;s available I&#8217;ll post a link.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.youell.com/matt/writing/?feed=rss2&amp;p=418</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Heads and Tails in Functional Programming</title>
		<link>http://www.youell.com/matt/writing/?p=101</link>
		<comments>http://www.youell.com/matt/writing/?p=101#comments</comments>
		<pubDate>Mon, 05 Jan 2009 09:48:16 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[functional programming]]></category>
		<category><![CDATA[humane]]></category>
		<category><![CDATA[programming languages]]></category>

		<guid isPermaLink="false">http://www.youell.com/matt/writing/?p=101</guid>
		<description><![CDATA[The other night I went to the first meeting of the PDX SICP Study Group down the road in The Beave. It was nice to finally be minutes away from a programmers meeting! (I live in the boonies.) I&#8217;m sure all future meetings will be on the east side now that I&#8217;ve said that. 
I&#8217;m [...]]]></description>
			<content:encoded><![CDATA[<p>The other night I went to the first meeting of the <a href="http://groups.google.com/group/pdx-sicp-studygroup/">PDX SICP Study Group</a> down the road in <a href="http://en.wikipedia.org/wiki/Beaverton,_Oregon">The Beave</a>. It was nice to finally be minutes away from a programmers meeting! (I live in the boonies.) I&#8217;m sure all future meetings will be on the east side now that I&#8217;ve said that. </p>
<p>I&#8217;m still a functional programming n00b. Which is funny to think about, because I probably know more about FP at this point than I knew about OOP many years ago when I was a junior programmer and considered myself something of an OO expert.</p>
<p>FP newbie or not, I&#8217;m still an experienced programmer with my own aesthetic sense of what qualifies as good code. One of the things that has always annoyed me about LISPs is their antiquated use of <code>car</code> and <code>cdr</code> as function names. Certainly once you&#8217;ve seen them enough you know exactly what they are and what they do. But as far as skimming code goes, they are awful. They aren&#8217;t clear or intuitive to new or casual readers. Even pronouncing <code>cdr</code> annoys me. (I want it to be &#8216;cedar&#8217;.  Instead it is &#8216;could-er&#8217; which sounds like a character from the Dukes of Hazzard.) I feel compelled to wrap them in my own functions just to make friendlier names like &#8216;first&#8217; and &#8216;rest&#8217;, or &#8216;head&#8217; and &#8216;tail&#8217;.</p>
<p>Other languages do use the head and tail metaphor directly. Erlang, which I enjoy programming with quite a bit, has an idiom where the head and tail metaphor shows up in the naming convention but not directly in syntax or function names. Instead of extracting the first item in a list with car and the rest of the items with cdr, you unpack the list with a pattern:</p>
<pre class="syntax-highlight:c">
Eshell V5.5.5  (abort with ^G)
1&gt; [H|T]=[1, 2, 3].
[1,2,3]
2&gt; H.
1
3&gt; T.
[2,3]
</pre>
<p>(Btw, Erlang&#8217;s pattern matching is far more powerful than I&#8217;m letting on here, and it makes this simple head/tail stuff look like child&#8217;s play.)</p>
<p>By convention it is understood that H stands for Head, and T for Tail.  And that&#8217;s fine, but what this idiom often means is that you end up declaring two or three variables for what essentially are views on a list. For example, during the SICP study group we solved a &#8220;change making&#8221; <a href="http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-11.html#%_sec_1.2.2">problem from Ch. 1</a>. Here&#8217;s the code I wrote in Erlang. I opted to replace H and T with domain-specific names:</p>
<pre class="syntax-highlight:c">
-module(change3).
-export([find_variations/2]).
-export([count_change/1]).

find_variations(0, _) -&gt; 1;		% No amount given.
find_variations(_, []) -&gt; 0;	% No coins given.
find_variations(Amount, _) 		% Amount is impossible.
	when Amount &lt; 0 -&gt; 0;

find_variations(Amount, [Coin|Rest]=Coins) -&gt;
	find_variations(Amount, Rest) + find_variations( (Amount - Coin),  Coins).

count_change(Amount) -&gt;
		find_variations(Amount, [50, 25, 10, 5, 1]).
</pre>
<p>The spot of interest here is the <code>find_variations</code> method matching <code>[Coin|Rest]=Coins</code>. This creates 3 variables which are, respectively, the first item from the list, the remaining list, and the original list itself. All of which get used in the function.</p>
<p>While I *looooove* the pattern matching in Erlang which allows these fairly clear variables to exist, I wonder if there might be a symbolic way to decorate the list variable to yield a particular view instead of requiring three separate variables to deal with. I came up with a few ideas, but I&#8217;m not sure I like any of these. Feedback is appreciated.</p>
<p><strong>Idea 1 &#8211; Graphically show head and tail</strong></p>
<p>Head:  <code><< List</code><br />
Tail: <code>List <<</code></p>
<p><strong>Idea 2 - Borrow from Regex Anchors</strong></p>
<p>Head:  <code>^List</code><br />
Tail: <code>List$</code></p>
<p><strong>Idea 3 - Misappropriate Perl's sigils</strong></p>
<p>Head: <code>$List</code>  (since the head is basically a scalar)<br />
Tail: <code>@List </code> (since the tail is a list)</p>
<p>All of these suck in their own way, but I think I like Idea #3 the best because it gives you the opportunity to treat a list in reverse without having to reverse it first:</p>
<p>Last item in list: <code>List$</code><br />
All items in list except last: <code>List@</code></p>
<p>If Erlang had a syntax like this (and thank god it doesn't), here's what that earlier function would look like, rewritten using syntax #3:</p>
<pre class="syntax-highlight:c">
find_variations(Amount, Coins) -&gt;
	find_variations(Amount, @Coins) + find_variations( (Amount - $Coins),  Coins).
</pre>
<p>I'd like to know what others think about this.</p>
<p>In closing, I'd like to note that Python, my day-to-day language, already has this flexibility using list slices:</p>
<pre class="syntax-highlight:python">
def find_variations(amount, coins):
	return find_variations(amount, coins[1:]) + find_variations( (amount - coins[0]),  coins)
</pre>
<p>Unfortunately, Python is designed to discourage recursion so this is sort of misleading. You wouldn't write a real solution this way in Python.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.youell.com/matt/writing/?feed=rss2&amp;p=101</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>If Programming Languages Were Martial Arts</title>
		<link>http://www.youell.com/matt/writing/?p=46</link>
		<comments>http://www.youell.com/matt/writing/?p=46#comments</comments>
		<pubDate>Wed, 17 Dec 2008 01:38:26 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[culture]]></category>
		<category><![CDATA[martial arts]]></category>
		<category><![CDATA[programming languages]]></category>

		<guid isPermaLink="false">http://www.youell.com/matt/writing/?p=46</guid>
		<description><![CDATA[A few weeks ago I was thinking about how various programming languages compare with the different martial arts. I decided that was a silly topic for a blog post. Today my fried Matt sent me a link to a page titled &#8220;If Programming Languages Were Religions&#8221; (as though they aren&#8217;t). And so I figured silly [...]]]></description>
			<content:encoded><![CDATA[<p>A few weeks ago I was thinking about how various programming languages compare with the different martial arts. I decided that was a silly topic for a blog post. Today my fried Matt sent me a link to a page titled &#8220;<a href="http://www.aegisub.net/2008/12/if-programming-languages-were-religions.html">If Programming Languages Were Religions</a>&#8221; (as though they aren&#8217;t). And so I figured silly or not, I&#8217;d do my martial arts version:</p>
<p><strong>Fortran</strong> would be <strong>Greco-Roman wrestling</strong>. You have to wear tights and there are a lot of lame rules. But if you&#8217;re good at it you can certainly pin a dude.</p>
<p><strong>Lisp</strong> would be <strong>Aikido</strong>. It is philosophical. It is elegant. It breaks things down to their essential components. It is dripping with the Tao. Unfortunately the schools are splintered and the focus seems to be more on finding The Way than kicking some dude&#8217;s ass in the parking lot.</p>
<p><strong>C</strong> would be plain old <strong>Karate</strong>. </p>
<p><strong>C++</strong> is <strong>Judo</strong>. It looks a lot like Karate until it throws you over its shoulder onto your head and your arm pops out of its socket.</p>
<p><strong>VB</strong> would be <strong>Western boxing</strong>. It can walk right up to a problem and punch it in the face. Of course there will be some mandatory bobbing and weaving and some fancy footwork for no apparent reason. And it&#8217;s all over if it gets taken to the ground.</p>
<p><strong>Perl</strong> would be <strong>Jujitsu</strong>. It isn&#8217;t as clear-cut as Karate or as elegant as Aikido, but it&#8217;s good on a battlefield when you run out of ammo. And it isn&#8217;t opposed to you using a rifle butt instead of your fist.</p>
<p><strong>Java</strong> would be <strong>Tai Chi</strong>. Everything is very slow and very formal and OMG after you&#8217;ve used it a little bit your muscles hurt like hell. So you&#8217;d never actually use it in a fight. But the payoff comes later with how light you feel when you&#8217;re kicking ass in any other language.</p>
<p><strong>Javascript</strong> would be <strong>Krav Maga</strong>. It isn&#8217;t just going to fuck you up, it&#8217;s going to kill you. It isn&#8217;t too particular about how and it knows a lot of ways to do it. Unfortunately it can only fight within 50 yards of its house because it&#8217;s on probation and has an ankle monitor.</p>
<p><strong>PHP</strong>  would be <strong>Tae Kwon Do</strong>. It&#8217;s that shit you learn at the strip mall when you&#8217;re 6 years old. You know, the place that puts the flag on your gi and their dojo name in huge letters on your back? Sure, you can kick someone&#8217;s ass with it &#8211; if they hold still and don&#8217;t fight back too hard. It is not <a href="http://www.thefootfistway.com/">a deadly killing system</a> &#8211; but you can do a spinning back-kick like no one&#8217;s business!</p>
<p><strong>Ruby</strong> would be <strong>Brazillian Jujitsu</strong>. It acknowledges that most real fights are messy and end up going to the ground, so why not specialize in winning that way?</p>
<p><strong>Erlang</strong> would be <strong>Wing Chun kung fu</strong>. It has a pragmatic fighting philosophy and is very effective, especially against multiple opponents. There are some restrictions on how you strike and move, and there are fewer moves than with other styles. Eventually you realize that is for the best.</p>
<p><strong>Haskell</strong> would be <strong>White Crane kung fu</strong>. There&#8217;s a lot of weird shit going on and no one seems to know it, but you just know that dude can fucking kill you with his death touch or whatever.</p>
<hr />
That&#8217;s what I&#8217;ve got right now. There are still some major languages missing which I couldn&#8217;t find matches for. Also, I tried to resist drawing parallels between the functional/object world and the soft/hard styles. It doesn&#8217;t really seem to work, and it would try to make Lisp a kung fu, which didn&#8217;t make a lot of sense to me.</p>
<p>Please feel free to leave suggestions or to correct me in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.youell.com/matt/writing/?feed=rss2&amp;p=46</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>What I want: Features as a first class programming concept</title>
		<link>http://www.youell.com/matt/writing/?p=27</link>
		<comments>http://www.youell.com/matt/writing/?p=27#comments</comments>
		<pubDate>Mon, 15 Sep 2008 02:44:07 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[programming languages]]></category>

		<guid isPermaLink="false">http://www.youell.com/matt/writing/?p=27</guid>
		<description><![CDATA[I&#8217;ve been mulling this idea over for quite some time now (years, actually) and I don&#8217;t really see how it would work. Otherwise I&#8217;d code it up.
Typically I develop software for clients over time instead of in one big shot. After an initial release the client will come back with feature requests which will lead [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been mulling this idea over for quite some time now (years, actually) and I don&#8217;t really see how it would work. Otherwise I&#8217;d code it up.</p>
<p>Typically I develop software for clients over time instead of in one big shot. After an initial release the client will come back with feature requests which will lead to new versions of the software. To make a new version of an app I code up all of the feature requests on top of the current version. In other words, given version A, I add features B and emit version C.</p>
<p>What I&#8217;d really like to do is to have control over each feature I add to the software. Certainly I could carefully track my development and create patches after ever feature is implemented. Then each feature would be separately controllable to some degree. But that doesn&#8217;t really accomplish much aside from allowing a bundle of features to be deployed. Each feature would still be linearly bound to other features and there would be no intelligence about dependencies.</p>
<p>If my client calls me up and says &#8220;feature B.3 isn&#8217;t as useful as we thought, pull it&#8221;, I&#8217;d like to be able to do that easily and on the fly, in production. In a perfect world I would do this from a config file or control panel somewhere. And if feature B.3 is required for features B.5 and B.42? Then those get turned off too, probably after a confirmation.</p>
<p>Like I said, I don&#8217;t really see how it would work. Real software is complicated and only gets more so as time goes on and features are added (or removed). Even the concept of what is or is not part of a given feature is subjective and could change over the life of the app. Features could and likely would cross boundaries of classes, functions, database tables, etc.</p>
<p>All of which sounds a lot like AOP.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.youell.com/matt/writing/?feed=rss2&amp;p=27</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>PHP: Pimp-Hand Programming</title>
		<link>http://www.youell.com/matt/writing/?p=26</link>
		<comments>http://www.youell.com/matt/writing/?p=26#comments</comments>
		<pubDate>Thu, 11 Sep 2008 20:52:11 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[programming languages]]></category>

		<guid isPermaLink="false">http://www.youell.com/matt/writing/?p=26</guid>
		<description><![CDATA[I&#8217;ve said before that I&#8217;m a hater. What I haven&#8217;t mentioned is that I&#8217;m also a snob. Especially about programming languages. I&#8217;m not bragging &#8211; this is a personal flaw. My feelings about languages have changed dramatically over the years though. I still have languages I&#8217;d rather not work with but I&#8217;m finding that there [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve said before that I&#8217;m a <a href="http://www.youell.com/matt/writing/?p=13">hater</a>. What I haven&#8217;t mentioned is that I&#8217;m also a snob. Especially about programming languages. I&#8217;m not bragging &#8211; this is a personal flaw. My feelings about languages have changed dramatically over the years though. I still have languages I&#8217;d rather not work with but I&#8217;m finding that there is some value in almost any popular language you can name.</p>
<p>PHP was pretty easy to blow off when I first came across it back in 2000. It looked like the inbred bastard love child of ASP and Perl. (I think that is still an accurate assessment btw.) Back then I was already shifting from doing web apps in C++ or Perl to doing them with JSP or ASP. I didn&#8217;t need to learn yet another way to do the same stuff.</p>
<p>I did give PHP a try a few years later, around 2003. I installed a Slashdot-style app written in PHP which I planned to customize. I didn&#8217;t get far. The app turned out to have security issues. Major, major security issues which took out my fancy-schmancy leased server. This was during a time when I was trying to bootstrap a one-man startup. I recovered most of my data and I had backups for the most important things, but I lost my development velocity completely. Losing velocity can be death to any startup, but it was certain death to an under-funded one-man show like mine. I ran out of cash shortly after I was hacked. My attitude about PHP didn&#8217;t improve. Fair or not, I decided that PHP was for morons and it didn&#8217;t have the maturity required for real apps.</p>
<p>Time passed. Old wounds healed, and I finally started to get curious about PHP again. Last fall I went book shopping. I picked up a book on Erlang, one on Python, and one on PHP. It look me a while to get around to reading it, but when I did I was impressed. PHP can do all sorts of wonderful things.</p>
<p>Things that are good about PHP:</p>
<ul>
<li>The culture values simplicity and efficiency.</li>
<li>It fills the gap left by classic ASP and it fulfills the same code-in-template need that ASP satisfied.</li>
<li>You can run it from the command line. That makes it very test-friendly.</li>
<li>It provides many features you&#8217;d want from an app server but it is still low level.</li>
<li>It is fast.</li>
<li>It&#8217;s available on a <em>huge</em> number of web servers in the world.</li>
</ul>
<p>Of course PHP isn&#8217;t all puppies and kittens. Here are some things that are bad about PHP:</p>
<ul>
<li>It&#8217;s a screwy improvised language which tries to look like Perl but works more like C but also sometimes like Python.</li>
<li>Its tag scheme sucks.</li>
<li>There are many gotchas and not everything works as advertised.</li>
<li>The learning curve is non-linear and downright rocky in places.</li>
</ul>
<p>While I certainly do NOT miss Visual Basic or VBScript, I really, really miss doing apps in classic ASP. I used to be dead-set against systems that mixed programmatic code and HTML together in the same file. But after many, many years of doing it several different ways I have to say that I prefer the ASP way in many &#8211; if not most &#8211; common situations. Mixed systems like ASP or PHP require discipline to use effectively but they also offer great power and flexibility.</p>
<p>So I now respect the hell out of PHP. But there&#8217;s just no way in hell I&#8217;m going to use it for many projects.</p>
<p>Why? Because those many items on the &#8220;good&#8221; list don&#8217;t make up for those few items on the &#8220;bad&#8221; list. PHP can be fairly simple to work with, but when you least expect it PHP can be a fucking bear. Just the other day I spent 4 hours fighting with PHP to get a simple filter working with my blog posts. Wordpress is written in PHP and it lets you create custom filters. All I needed was some regex love in my filter. In Perl it would have taken me no more than 25-30 minutes. (And that&#8217;s because my Perl is rusty. If my Perl skizillz were current I would have been done in about 90 seconds. Seriously. It was a small task.) But I could never get it working the way I wanted it to in PHP. I eventually gave up and fell back to manual split/substr style filtering like I used to do when I was a newbie programmer and didn&#8217;t know any better. I&#8217;m almost as pissed about the inelegant solution as I am about losing 3-4 hours for no good reason.</p>
<p>This doesn&#8217;t mean I&#8217;m done with PHP though. I&#8217;ve been thinking about this for a while now, and I&#8217;ve come to the conclusion that PHP can be to the web what C is to Unix. Think of it as a portable assembler for the web. PHP runs everywhere and it&#8217;s fairly straightforward and also fairly low level. PHP also has some added mojo because it is naturally <a href="http://phplens.com/phpeverywhere/?q=node/view/254">parallizable</a>. PHP would make a wonderful target language for a &#8220;little language&#8221; compiler. Especially for a distributed solution.</p>
<p>I know that there is already Fogcreek&#8217;s <a href="http://www.fogcreek.com/FogBugz/blog/post/The-Origin-of-Wasabi.aspx">Wasabi</a>. But that&#8217;s not exactly what I&#8217;m talking about. Joel and Co. have solved only their own product problems and it sounds more like language translation than compilation. Wasabi (near as I can tell since it isn&#8217;t publicly available) doesn&#8217;t go all the way with the idea. I&#8217;m saying, GO ALL THE WAY. Make your own compiler that spits out PHP. I&#8217;m not saying compile Ruby to PHP so you can run Rails on it. That&#8217;s kind of nuts. (But hey, no one is stopping you.) Instead, I&#8217;m saying that you can take that custom DSL you created in <a href="http://www.paulgraham.com/avg.html">Blub</a> and implement it as your own little language. Have it output PHP and see what happens. That&#8217;s what I&#8217;m going to do. I think it&#8217;ll be a lot of fun.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.youell.com/matt/writing/?feed=rss2&amp;p=26</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
