<?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>Excursus &#187; kdiff3</title>
	<atom:link href="http://markelikalderon.com/category/diff/kdiff3/feed/" rel="self" type="application/rss+xml" />
	<link>http://markelikalderon.com</link>
	<description>Philosophy and Text</description>
	<lastBuildDate>Tue, 27 Dec 2011 23:01:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Diff Programs Diffed</title>
		<link>http://markelikalderon.com/2007/02/15/diff-programs-diffed/</link>
		<comments>http://markelikalderon.com/2007/02/15/diff-programs-diffed/#comments</comments>
		<pubDate>Thu, 15 Feb 2007 22:38:28 +0000</pubDate>
		<dc:creator>Mark Eli Kalderon</dc:creator>
				<category><![CDATA[FileMerge]]></category>
		<category><![CDATA[GNU diff]]></category>
		<category><![CDATA[Hybrid Application]]></category>
		<category><![CDATA[Text]]></category>
		<category><![CDATA[diff]]></category>
		<category><![CDATA[kdiff3]]></category>
		<category><![CDATA[wdiff]]></category>

		<guid isPermaLink="false">http://markelikalderon.com/blog/blog/2007/02/15/diff-programs-diffed/</guid>
		<description><![CDATA[In my very first post, I mentioned that a lot of tools for programmers are readily adapted to the task of writing. When writing long, complex documents, it is sometimes necessary to compare versions. If you have embraced the power of plain text, a diff program can help. Diff programs display differences between files. This [...]]]></description>
			<content:encoded><![CDATA[<p>In my very first <a href="http://markelikalderon.com/blog/blog/2006/09/27/the-word/">post</a>, I mentioned that a lot of tools for programmers are readily adapted to the task of writing. When writing long, complex documents, it is sometimes necessary to compare versions. If you have embraced <a href="http://markelikalderon.com/blog/blog/2006/10/25/plain-text/">the power of plain text</a>, a diff program can help. Diff programs display differences between files. This post will examine a number of different diff programs from a writer&#8217;s perspective.</p>

<p>As our sample text we will use the following passage from <em>Moby Dick</em> (available at <a href="http://www.gutenberg.org/wiki/Main_Page">Project Gutenberg</a>):</p>

<blockquote>
  <p>While Daggoo and Queequeg were stopping the strained planks; and as the whale swimming out from them, turned, and showed one entire flank as he shot by them again; at that moment a quick cry went up. Lashed round and round to the fish&#8217;s back; pinioned in the turns upon turns in which, during the past night, the whale had reeled the involutions of the lines around him, the half torn body of the Parsee was seen; his sable raiment frayed to shreds; his distended eyes turned full upon old Ahab.</p>
  
  <p>The harpoon dropped from his hand.</p>
</blockquote>

<p>and this slightly modified version:</p>

<blockquote>
  <p>While Dagoo and Queequeg were stopping the strained planks; and as the whale swimming out from them, turned, and showed one entir flank as he shot by them again; at that moment a quick crie went up. Lashed round and round to the fish&#8217;s back; pinioned in the turns upon turns in which, during the past night, the whale had reeled the involutions of the lines around him, the half torn body of the Parsee was seen; his sable raiment frayed to shreds; his distended eyes turned full upon old Ahab.</p>
  
  <p>The harpoon dropped from his hand.</p>
</blockquote>

<p>I saved these as text files called, respectively, passageone.txt and passagetwo.txt.</p>

<p>First up is <a href="www.gnu.org/">GNU</a> <a href="http://www.gnu.org/software/diffutils/">diff</a>. See the man page for diff&#8217;s options. An extensive manual is provided by Texinfo. Simply type:</p>

<pre><code>info diff
</code></pre>

<p>in the terminal. The command:</p>

<pre><code>diff passageone.txt passagetwo.txt
</code></pre>

<p>yields the following output:</p>

<pre><code>1c1
&lt; While Daggoo and Queequeg were stopping the strained planks; and as the whale swimming out from them, turned, and showed one entire flank as he shot by them again; at that moment a quick cry went up. Lashed round and round to the fish's back; pinioned in the turns upon turns in which, during the past night, the whale had reeled the involutions of the lines around him, the half torn body of the Parsee was seen; his sable raiment frayed to shreds; his distended eyes turned full upon old Ahab. 
---
&gt; While Dagoo and Queequeg were stopping the strained planks; and as the whale swimming out from them, turned, and showed one entir flank as he shot by them again; at that moment a quick crie went up. Lashed round and round to the fish's back; pinioned in the turns upon turns in which, during the past night, the whale had reeled the involutions of the lines around him, the half torn body of the Parsee was seen; his sable raiment frayed to shreds; his distended eyes turned full upon old Ahab. 
3c3
&lt;    The harpoon dropped from his hand.
---
&gt; The harpoon dropped from his hand.
\ No newline at end of file
</code></pre>

<p>One limitation, from the writer&#8217;s perspective is immediately apparent. GNU diff compares <em>line differences</em>. But as paragraphs are long lines, multiple differences within a paragraph are not displayed. What would be more useful is a representation of <em>word differences</em>.</p>

<p>Fortunately, there is a frontend for GNU diff that displays word differences, <a href="http://wdiff.progiciels-bpi.ca/">wdiff</a>. wdiff is available from <a href="http://fink.sourceforge.net/">fink</a> and <a href="http://www.macports.org/">MacPorts</a>. The command:</p>

<pre><code>wdiff passageone.txt passagetwo.txt
</code></pre>

<p>yields the following output:</p>

<pre><code>While [-Daggoo-] {+Dagoo+} and Queequeg were stopping the strained planks; and as the whale swimming out from them, turned, and showed one [-entire-] {+entir+} flank as he shot by them again; at that moment a quick [-cry-] {+crie+} went up. Lashed round and round to the fish's back; pinioned in the turns upon turns in which, during the past night, the whale had reeled the involutions of the lines around him, the half torn body of the Parsee was seen; his sable raiment frayed to shreds; his distended eyes turned full upon old Ahab. 

The harpoon dropped from his hand.
</code></pre>

<p>[-foo-] is a word that occurs in passageone.txt and {+foo+} is a word that occurs in passagetwo.txt.</p>

<p>In an earlier <a href="http://markelikalderon.com/blog/blog/2006/11/02/atpm-on-activity-monitor/">post</a> I observed that the GUI has its place even in the manipulation of text. If you install the <a href="http://en.wikipedia.org/wiki/Apple_Developer_Tools">developer tools</a> on Mac OS X, one gem that you will get is FileMerge, a descendant of <a href="http://en.wikipedia.org/wiki/NEXTSTEP">NEXTSTEP</a>&#8217;s Merge utility. FileMerge provides a visual comparison of text files. FileMerge can be invoked from the command line with opendiff. A screenshot of the output is below:</p>

<p><a class="imagelink" href="http://markelikalderon.com/wp-content/uploads/2007/02/filemerge.jpg" title="FileMerge"><img id="image119" src="http://markelikalderon.com/wp-content/uploads/2007/02/filemerge.thumbnail.jpg" alt="FileMerge" /></a></p>

<p>Notice, FileMerge, like GNU diff, captures line differences, but, like wdiff, it also highlights word differences.</p>

<p>FileMerge is Apple software, so it is simple and easy to use. If you need a more powerful GUI diff program, <a href="http://kdiff3.sourceforge.net/">kdiff3</a> might be for you. Here&#8217;s a screenshot:</p>

<p><a class="imagelink" href="http://markelikalderon.com/wp-content/uploads/2007/02/kdiff3.jpg" title="kdiff3"><img id="image120" src="http://markelikalderon.com/wp-content/uploads/2007/02/kdiff3.thumbnail.jpg" alt="kdiff3" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://markelikalderon.com/2007/02/15/diff-programs-diffed/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

