<?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>skrud.net &#187; programming</title>
	<atom:link href="http://skrud.com/articles/tag/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://skrud.com</link>
	<description>Trust Your Geekflex</description>
	<lastBuildDate>Mon, 24 Nov 2008 20:13:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>ooPSLA 2007</title>
		<link>http://skrud.com/articles/2007/10/26/oopsla-2007/</link>
		<comments>http://skrud.com/articles/2007/10/26/oopsla-2007/#comments</comments>
		<pubDate>Fri, 26 Oct 2007 22:37:59 +0000</pubDate>
		<dc:creator>Skrud</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[2007]]></category>
		<category><![CDATA[oopsla]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[soen]]></category>

		<guid isPermaLink="false">http://www.skrud.net/articles/2007/10/26/oopsla-2007/</guid>
		<description><![CDATA[Attending ooPSLA was a phenomenal experience. My brain has been working overtime, at 150% efficiency, to try and understand and make sense of everything I&#8217;ve seen and heard and read this past week. I felt like I understood quite a bit, but I was challenged by even more. For each nugget of golden information I [...]]]></description>
			<content:encoded><![CDATA[<p>Attending <a href="http://www.oopsla.org">ooPSLA</a> was a phenomenal experience. My brain has been working overtime, at 150% efficiency, to try and understand and make sense of everything I&#8217;ve seen and heard and read this past week. I felt like I understood quite a bit, but I was challenged by even more. For each nugget of golden information I managed to get out of a particular lecture, I&#8217;m sure there were many more that flew a few thousand metres over my head. Whatever I write about here is <a href="http://www.oopsla.org">ooPSLA</a> as I was able to understand it, and I probably got a few things wrong.</p>

<p>I was scribbling notes during each lecture I attended, and going over them I can see one theme that permeated the entire conference more than any other: <strong>communication</strong>, starting with <a href="http://www.skrud.net/articles/2007/10/23/software-design-is-a-social-activity/">DesignFest</a>, which was the first event I went to.</p>

<p>Software engineers face an infinite number of challenges involving communication. We&#8217;re not only talking about communication between software designers and customers, but also between software engineers and <em>each other</em>. How do you get people to communicate clearly and precisely? How can you distribute the intellectual work of software design and still maintain <a href="http://c2.com/cgi/wiki?ConceptualIntegrity">Conceptual Integrity</a>? You need to be able to not only work together with someone face-to-face, but more and more you need to be able to work with people <em>in other places</em>, so called &#8220;telecollaboration&#8221; (more on this topic when I write about Fred Brooks&#8217; keynote).</p>

<p>Think about the overhead and the time it takes in order to make another person understand the design you have going on in your head? UML models can only express so much, but they have their limits (as does <em>any</em> language). That&#8217;s why there were even tutorials, such as the one I attended – &#8220;The Art of Telling Your Design Story&#8221;, by <a href="http://www.wirfs-brock.com/rebeccasblog.html">Rebecca Wirfs-Brock</a> – which are all about <em>how</em> to communicate your design to someone else.</p>

<p>As a whole, ooPSLA was a <em>legendary</em> experience that I never want to forget. This is one more aspect of my life that I have to thank <a href="http://www.grrly.net">Dominique</a> for. She told me about the ooPSLA Student Volunteer program, and if it weren&#8217;t that I probably never would&#8217;ve even found out that the conference was in Montreal! Thanks, Dom! :D</p>
]]></content:encoded>
			<wfw:commentRss>http://skrud.com/articles/2007/10/26/oopsla-2007/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Peter Turchi: Getting Lost is a Good Thing</title>
		<link>http://skrud.com/articles/2007/10/26/peter-turchi-getting-lost-is-a-good-thing/</link>
		<comments>http://skrud.com/articles/2007/10/26/peter-turchi-getting-lost-is-a-good-thing/#comments</comments>
		<pubDate>Fri, 26 Oct 2007 22:23:42 +0000</pubDate>
		<dc:creator>Skrud</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[2007]]></category>
		<category><![CDATA[events]]></category>
		<category><![CDATA[oopsla]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.skrud.net/articles/2007/10/26/peter-turchi-getting-lost-is-a-good-thing/</guid>
		<description><![CDATA[The opening keynote of ooPSLA was not a geek. In fact, he opened up his speech saying &#8220;I don&#8217;t do what you do.&#8221; Peter Turchi heads an MFA Program for Writers in North Carolina. So what was he doing at a conference on &#8220;Object Oriented Programming, Systems, Languages and Applications?&#8221;

It turns out that conference chair [...]]]></description>
			<content:encoded><![CDATA[<p>The opening keynote of <a href="http://www.dreamsongs.com/">ooPSLA</a> was <em>not</em> a geek. In fact, he opened up his speech saying &#8220;I don&#8217;t do what you do.&#8221; Peter Turchi heads an MFA Program for Writers in North Carolina. So what was he doing at a conference on &#8220;Object Oriented Programming, Systems, Languages and Applications?&#8221;</p>

<p>It turns out that conference chair <a href="http://www.dreamsongs.com/">Dick Gabriel</a> had once decided to take an MFA program. He was not terribly good at it (though he continues to write a poem every day). Peter Turchi was his teacher. What contribution could a Creative Writing professor possibly have at a conference on Software Engineering? I&#8217;ll tell you.</p>

<p>The purpose of Turchi&#8217;s talk wasn&#8217;t to present some radical new paradigm of programming, and it wasn&#8217;t to show off some fantastical form of research. The theme of Turchi&#8217;s talk, was that <em>getting lost can be a good thing</em>. When you get lost, you have to find your way back. In the process of finding your way back, <strong>you learn a new path</strong>. And sometimes, that is how you have to learn. In order to succeed and innovate, and create something new, you have to get lost in it.</p>

<p>If you have a map, you might be worse off than if you had no map at all. When using maps, you have to realize that <strong>all maps are distortions</strong>. No map tells the truth. Think about the typical world map that you&#8217;d see almost anywhere:</p>

<p><a href='http://www.skrud.net/articles/2007/10/26/peter-turchi-getting-lost-is-a-good-thing/traditional-world-map/' rel='attachment wp-att-2456' title='Traditional World Map'><img src='http://www.skrud.net/files/world-map-2.thumbnail.png' alt='Traditional World Map' /></a></p>

<p>You&#8217;re pretty used to seeing it, so it won&#8217;t look particularly strange to you. But what about this &#8220;Upside-Down&#8221; world map?</p>

<p><a href='http://www.skrud.net/articles/2007/10/26/peter-turchi-getting-lost-is-a-good-thing/upside-down-world-map/' rel='attachment wp-att-2457' title='Upside-down World Map'><img src='http://www.skrud.net/files/diversophy-large.thumbnail.jpg' alt='Upside-down World Map' /></a></p>

<p>It&#8217;s the same planet, and there&#8217;s no real &#8220;up&#8221; direction, so it&#8217;s just as accurate as any other map &#8230; but it&#8217;s still a distortion. The point is that <strong>no map is accurate</strong>, and if we rely too often on a single distortion (or abstraction), we will lose sight of our destination. We will get stuck in a certain paradigm, and be unable to &#8220;get lost&#8221; and discover a new path or a new perspective.</p>

<p>The parallels to software engineering are profound. A &#8220;map&#8221; can be some predefined solution to a problem; like a design pattern. There&#8217;s nothing wrong with using design patterns, sure they help, sure they show us useful and reliable information, so do maps. But we have to understand that design patterns themselves are an abstraction. Our purpose as software engineers and developers and programmers is to <em>solve a problem</em>, not to blindly trust and apply design patterns. We need to be able to get lost in a problem, and force ourselves to find a way out.</p>
]]></content:encoded>
			<wfw:commentRss>http://skrud.com/articles/2007/10/26/peter-turchi-getting-lost-is-a-good-thing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A strange (Java IO) coincidence?</title>
		<link>http://skrud.com/articles/2006/08/16/a-strange-java-io-coincidence/</link>
		<comments>http://skrud.com/articles/2006/08/16/a-strange-java-io-coincidence/#comments</comments>
		<pubDate>Wed, 16 Aug 2006 23:27:00 +0000</pubDate>
		<dc:creator>Skrud</dc:creator>
				<category><![CDATA[geek]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.skrud.net/2006/08/16/a-strange-java-io-coincidence/</guid>
		<description><![CDATA[This is kind of an aside and update to my previous post&#8230;

I was walking around the office today and I noticed a printed sheet sticking out of a printer that caught my eye.  It was a printed version of this page.  Look familiar?

Even more of a coincidence, the author of that page is [...]]]></description>
			<content:encoded><![CDATA[<p>This is kind of an aside and update to my <a href="http://skrud.net/articles/2006/08/14/verbosity-is-evil">previous post</a>&#8230;</p>

<p>I was walking around the office today and I noticed a printed sheet sticking out of a printer that caught my eye.  It was a printed version of <a href="http://www.cafeaulait.org/slides/intljava/2001ny/javaio/57.html">this page</a>.  Look familiar?</p>

<p>Even more of a coincidence, the author of that page is <a href="http://www.cafeaulait.org">Elliot Rusty Harold</a> who, in addition to writing <a href="http://www.cafeaulait.org/books/">entire books</a> on the subject of Java IO made himself known to the Ruby community when he more or less sparked the infamous <a href="http://farm.tucows.com/blog/_archives/2005/12/9/1443435.html">Monkey Knife Fight</a> a while back about <a href="http://www.skrud.net/articles/2005/12/10/minimal-vs-humane-interfaces">Minimal vs. Humane Interfaces</a>, which is the last time I think I had a serious code-related discussion on my blog.</p>
]]></content:encoded>
			<wfw:commentRss>http://skrud.com/articles/2006/08/16/a-strange-java-io-coincidence/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Verbosity is Evil</title>
		<link>http://skrud.com/articles/2006/08/14/verbosity-is-evil/</link>
		<comments>http://skrud.com/articles/2006/08/14/verbosity-is-evil/#comments</comments>
		<pubDate>Tue, 15 Aug 2006 00:43:00 +0000</pubDate>
		<dc:creator>Skrud</dc:creator>
				<category><![CDATA[geek]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[rants]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.skrud.net/2006/08/14/verbosity-is-evil/</guid>
		<description><![CDATA[Programming in Java is like a rollercoaster. At first I hated it. Then I started to like it a bit&#8230;. Then I hated it again. Then I discovered the robustness and completeness of Java&#8217;s Standard Library, and I started to like it again. Now I still appreciate the library, but I hate the language.  [...]]]></description>
			<content:encoded><![CDATA[<p>Programming in <a href="http://java.sun.com">Java</a> is like a rollercoaster. At first I hated it. Then I started to like it a bit&#8230;. Then I hated it again. Then I discovered the robustness and completeness of Java&#8217;s Standard Library, and I started to like it again. Now I still appreciate the library, but I <em>hate</em> the language.  The Java Programming language is probably <a href="http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html">one of the most <em>verbose</em> languages in existence</a>. It takes a lot of effort just to express some of the simplest things.</p>

<p>I think this is because the design philosophy of Java is anal-retentive to the extreme.  The library _is_ well-designed, but to the detriment of the programmer who has to deal with the textual overhead that all this flexibility demands.  Take a simple example of a program that writes a text file to the screen.  This is an extremely basic thing to do. Here is what it looks like in Java:</p>

<div class="typocode"><pre><code class="typocode_java ">public class FileRead {
    static void printFile(String filename) {
        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(
                    new FileInputStream(new File(filename))));
            String line;
            while ((line = reader.readLine()) != null) {
                System.out.println(line);
            }
        } catch (FileNotFoundException e) {
            System.err.printf(&quot;No such file found: %s\n&quot;, filename);
        } catch (IOException e) {
            System.err.println(&quot;Error reading from file.&quot;);
        }
    }

    public static void main(String[] args) {
        if (args.length == 1)
            printFile(args[0]);
    }

}</code></pre></div>

<p>(I actually googled for a while hoping to find a shorter version of this thing, and I actually couldn&#8217;t. I spent a good ten minutes thinking &#8220;It can&#8217;t seriously be this long&#8230;&#8221;).</p>

<p>There are <em>good reasons</em> why this sort of program needs to be written this way.  We want to read from a <tt>File</tt>, so we create a <tt>File</tt>, and a <tt>FileInputStream</tt> to read from it.  The <tt>FileInputStream</tt> basically gives us a sequence of characters from the file, and implements an <tt>InputStream</tt> interface which <em>all InputStream</em>-type things share.  This means that a FileInputStream can easily be interchanged with an InputStream from some other source &#8211; this is (in the &#8220;big picture&#8221;) a good thing, because it&#8217;s generic.</p>

<p>But I want to <em>read</em> from the file. So I need to convert that InputStream into something that can actually do <em>reading</em>, which is a <tt>Reader</tt>. An <tt>InputStreamReader</tt> converts an Input Stream to a Reader. But I want to read from my file <em>one line at a time</em>. That means I need to use a specific kind of <tt>Reader</tt> that lets me read by the line. That&#8217;s <tt>BufferedReader</tt>.  And that&#8217;s why we have that really long line of code that&#8217;s creating a file, an input stream, and input stream reader and a buffered reader.</p>

<p>Also notice that we actually are <em>forced</em> to deal with the <tt>FileNotFoundException</tt> and the <tt>IOException</tt> errors. So in case something goes wrong with the file and reading process, we are <em>forced</em> to handle the error. In a lot of cases, this is a good thing &#8211; it means that the compiler won&#8217;t let you get away with some potential bugs.  But what if we explicitly checked that the file existed before trying to read from it? What if we did:</p>

<div class="typocode"><pre><code class="typocode_java ">File file = new File(filename);
if ( !file.exists() ) // ...</code></pre></div>

<p>Well, we&#8217;d still have to handle the FileNotFoundException even if it would never, ever, ever occur because we&#8217;re checking for the file&#8217;s existence. That&#8217;s making things kind of messy. Plus &#8211; what if it&#8217;s a <em>perfectly normal thing</em> to have a file not exist? By definition, it wouldn&#8217;t be an <em>Exception</em>, but we have to handle the error anyway because Java has decided that we have to deal with <tt>FileNotFoundException</tt> no matter where it may be.</p>

<p>All this just means I have to write a lot more code than I should.</p>

<p>To contrast, here&#8217;s a Ruby program that does the <em>exact same thing</em>:</p>

<div class="typocode"><pre><code class="typocode_ruby "><span class="ident">filename</span> <span class="punct">=</span> <span class="constant">ARGV</span><span class="punct">[</span><span class="number">0</span><span class="punct">]</span>
<span class="ident">open</span><span class="punct">(</span><span class="ident">filename</span><span class="punct">).</span><span class="ident">each_line</span> <span class="punct">{</span> <span class="punct">|</span><span class="ident">line</span><span class="punct">|</span> <span class="ident">print</span> <span class="ident">line</span> <span class="punct">}</span></code></pre></div>

<p>Wow. It&#8217;s basically one line. And it even reads like English &#8220;Open filename, each line print line&#8221;.  You don&#8217;t even have to be a programmer to figure out what that does.  Mind you, what if &#8220;filename&#8221; doesn&#8217;t exist? You&#8217;re right, I&#8217;m not checking for any of the errors here. If the file doesn&#8217;t exist, the program will just exit with an error. But I guess just to push things closer to the Java version, I&#8217;ll add some error-handling.</p>

<div class="typocode"><pre><code class="typocode_ruby "><span class="ident">filename</span> <span class="punct">=</span> <span class="constant">ARGV</span><span class="punct">[</span><span class="number">0</span><span class="punct">]</span> <span class="keyword">or</span> <span class="keyword">raise</span> <span class="constant">ArgumentError</span><span class="punct">.</span><span class="ident">new</span><span class="punct">(&quot;</span><span class="string">No filename provided</span><span class="punct">&quot;)</span>

<span class="keyword">begin</span>
  <span class="ident">open</span><span class="punct">(</span><span class="ident">filename</span><span class="punct">).</span><span class="ident">each_line</span> <span class="punct">{</span> <span class="punct">|</span><span class="ident">line</span><span class="punct">|</span>
    <span class="ident">print</span> <span class="ident">line</span>
  <span class="punct">}</span>
<span class="keyword">rescue</span> <span class="constant">Errno</span><span class="punct">::</span><span class="constant">ENOENT</span>
  <span class="global">$stderr</span><span class="punct">.</span><span class="ident">puts</span><span class="punct">(&quot;</span><span class="string">No such file: <span class="expr">#{filename}</span></span><span class="punct">&quot;)</span>
<span class="keyword">end</span></code></pre></div>

<p>I think that&#8217;s still pretty clean, even though the <tt>ENOENT</tt> might throw you off if you didn&#8217;t know it meant &#8220;No Entry&#8221;.</p>

<p>What about Python?</p>

<div class="typocode"><pre><code class="typocode_python ">from sys import argv

if len( argv ) == 2:
    try:
        file = open( argv[1] )
        for line in file.readlines():
            print line,
    except IOError:
        print &quot;Error reading from the file.&quot;
else:
    print &quot;No file specified.&quot;</code></pre></div>

<p>Hey! That&#8217;s also really short. It just calls &#8220;open&#8221; and then loops over all the lines in the file. It doesn&#8217;t take a Computer Scientist to figure out what &#8220;file.readlines()&#8221; ought to do.</p>

<p>My point is that while Java is great at maintaining a generic, flexible design, it&#8217;s not very good at <em>revealing the intentions of the programmer</em>. I don&#8217;t think that code in Java is very readable, because you need to understand all the inner workings of the Java Library in order to understand what a simple piece of code that prints a file to the screen does.  And I don&#8217;t think that should be necessary.  I think you should be able to look at a piece of code and see &#8220;Oh, &#8216;print each line of the file&#8217;&#8221;. Any programming language that is as close as possible to &#8220;print each line from file&#8221; is certainly revealing the intentions of the programmer, and therefore is <em>much</em> easier to read and follow.</p>

<p>Java is great at revealing the internal workings of the library &#8211; waitaminute, isn&#8217;t that in contradiction to good Object Oriented Design? Aren&#8217;t you supposed to encapsulate and <em>hide away</em> your implementation details so that nobody needs to know how they work? Why then do I need to know that a File needs to be read through an InputStream and converted to a Reader and finally read? Why do I need to know that BufferedReader and LineNumberReader are the only Readers that let me <em>read one line at a time</em>?</p>

<p><strong>WHY CAN&#8217;T I JUST SAY &#8220;FROM FILE PRINT EACH LINE&#8221;?</strong></p>

<p><a href="http://en.wikipedia.org/wiki/Alan_Kay">Alan Kay</a> has a very famous quote:</p>

<blockquote>
    <p>Simple things should be simple and complex things should be possible.</p>
</blockquote>

<p>Java makes complicated things possible, and simple things complicated. There is a huge variance between the <em>code you write</em> and the <em>thing you want to be doing</em>. I think the closer those are, the better.</p>
]]></content:encoded>
			<wfw:commentRss>http://skrud.com/articles/2006/08/14/verbosity-is-evil/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Great Programmers Speak Out</title>
		<link>http://skrud.com/articles/2006/07/24/great-programmers-speak-out/</link>
		<comments>http://skrud.com/articles/2006/07/24/great-programmers-speak-out/#comments</comments>
		<pubDate>Mon, 24 Jul 2006 13:56:46 +0000</pubDate>
		<dc:creator>Skrud</dc:creator>
				<category><![CDATA[culture]]></category>
		<category><![CDATA[geek]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.skrud.net/2006/07/24/great-programmers-speak-out/</guid>
		<description><![CDATA[A number of top names in programming were recently interviewed, being asked questions ranging from how they learned to program, how useful is math (really), and which books they read. The interviewees include Linus Torvalds, the creator of the Linux operating system and Steve Yegge, one of my favourite bloggers. Java creator James Gosling and [...]]]></description>
			<content:encoded><![CDATA[<p>A number of top names in programming were <a href="http://sztywny.titaniumhosting.com/2006/07/23/stiff-asks-great-programmers-answers/">recently interviewed</a>, being asked questions ranging from how they learned to program, how useful is math (really), and which books they read. The interviewees include Linus Torvalds, the creator of the Linux operating system and <a href="http://steve-yegge.blogspot.com/">Steve Yegge</a>, one of my favourite bloggers. Java creator James Gosling and Python creator Guido van Rossum are also on the roster, as is David Heinemeier Hansson of <a href="http://www.rubyonrails.org">Ruby on Rails</a> fame and a number of others.</p>

<p>Even if you haven&#8217;t heard of any of these programmers, if you have even the slightest interest in programming I highly suggest reading <a href="http://sztywny.titaniumhosting.com/2006/07/23/stiff-asks-great-programmers-answers/">the article</a>. The insights are pretty interesting.</p>
]]></content:encoded>
			<wfw:commentRss>http://skrud.com/articles/2006/07/24/great-programmers-speak-out/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
