<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Kernighan &amp; Plauger on Programming Style</title>
	<atom:link href="http://ashutoshmehra.net/blog/2009/06/kernighan-plauger-programming-style/feed/" rel="self" type="application/rss+xml" />
	<link>http://ashutoshmehra.net/blog/2009/06/kernighan-plauger-programming-style/</link>
	<description>Notes on Math, Computer Science &#38; Programming</description>
	<lastBuildDate>Thu, 29 Jul 2010 04:20:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Ashutosh</title>
		<link>http://ashutoshmehra.net/blog/2009/06/kernighan-plauger-programming-style/comment-page-1/#comment-993</link>
		<dc:creator>Ashutosh</dc:creator>
		<pubDate>Mon, 13 Jul 2009 18:07:52 +0000</pubDate>
		<guid isPermaLink="false">http://ashutoshmehra.net/blog/?p=556#comment-993</guid>
		<description>Thanks for the comment, Sam.

While the book doesn&#039;t ever mention &quot;functional programming&quot;, many of K&amp;P&#039;s suggestions, as you said, work nicely with FP:

Functions in FP tend to be naturally small: It is interesting to ponder what makes programming with FP-flavor lead naturally to smaller, shorter, more concise functions. It could well be that this is my personal feeling because I&#039;ve never really programmed &quot;real-world&quot; programs to solve &quot;real&quot; problems. But I suspect it is more generally true: Functions in imperative languages tend to be longer.

Functions in FP are more loosely coupled. Again, this is arguable. But I think using lists or property-bags as common data-structures leads to looser coupling.

And of course, FP eliminates a whole variety of errors related to order of assignment, uninitialized variables, using evil control structures... &lt;i&gt;FP is good&lt;/i&gt;.

As for top-down design, &quot;successive refinement&quot; does seem to be a good way to &lt;i&gt;understand&lt;/i&gt; a solution, if not necessarily &lt;i&gt;design&lt;/i&gt; one -- it helps understand the interactions between the players before delving in details on how each one does its job.

Perhaps top-down vs. bottom-up is like this: Which do you do first when coding or defining a recursive function -- code the &quot;recursion part&quot; first, or, code the base case first? Most times, I think, it is more natural do the &quot;recursion part&quot; first, if only because it helps clarify what the base cases should be -- precisely the cases for which it makes no further sense to subdivide the problem to conquer it!

But Top-down vs. Bottom-up is surely controversial, so I will not speak more ;-)

I remember, Alex Stepanov once gave a lecture here at our Adobe office, and there was a fair bit of discussion around this point. I actually cannot remember which, if any, side he spoke for. However, see page 5 of his &lt;a href=&quot;http://www.stepanovpapers.com/notes.pdf&quot; rel=&quot;nofollow&quot;&gt;notes on programming&lt;/a&gt;. There, he tries to be promoting a view alternative to top-down design, perhaps mostly to encourage the reader to appreciate the &quot;bottom&quot; of software -- data-structures, algorithms and complexity -- stuff which too many &quot;pattern-oriented&quot; designs consider secondary. When phrased like that, I personally, am all for the bottom of it!</description>
		<content:encoded><![CDATA[<p>Thanks for the comment, Sam.</p>
<p>While the book doesn&#8217;t ever mention &#8220;functional programming&#8221;, many of K&#038;P&#8217;s suggestions, as you said, work nicely with FP:</p>
<p>Functions in FP tend to be naturally small: It is interesting to ponder what makes programming with FP-flavor lead naturally to smaller, shorter, more concise functions. It could well be that this is my personal feeling because I&#8217;ve never really programmed &#8220;real-world&#8221; programs to solve &#8220;real&#8221; problems. But I suspect it is more generally true: Functions in imperative languages tend to be longer.</p>
<p>Functions in FP are more loosely coupled. Again, this is arguable. But I think using lists or property-bags as common data-structures leads to looser coupling.</p>
<p>And of course, FP eliminates a whole variety of errors related to order of assignment, uninitialized variables, using evil control structures&#8230; <i>FP is good</i>.</p>
<p>As for top-down design, &#8220;successive refinement&#8221; does seem to be a good way to <i>understand</i> a solution, if not necessarily <i>design</i> one &#8212; it helps understand the interactions between the players before delving in details on how each one does its job.</p>
<p>Perhaps top-down vs. bottom-up is like this: Which do you do first when coding or defining a recursive function &#8212; code the &#8220;recursion part&#8221; first, or, code the base case first? Most times, I think, it is more natural do the &#8220;recursion part&#8221; first, if only because it helps clarify what the base cases should be &#8212; precisely the cases for which it makes no further sense to subdivide the problem to conquer it!</p>
<p>But Top-down vs. Bottom-up is surely controversial, so I will not speak more ;-)</p>
<p>I remember, Alex Stepanov once gave a lecture here at our Adobe office, and there was a fair bit of discussion around this point. I actually cannot remember which, if any, side he spoke for. However, see page 5 of his <a href="http://www.stepanovpapers.com/notes.pdf" rel="nofollow">notes on programming</a>. There, he tries to be promoting a view alternative to top-down design, perhaps mostly to encourage the reader to appreciate the &#8220;bottom&#8221; of software &#8212; data-structures, algorithms and complexity &#8212; stuff which too many &#8220;pattern-oriented&#8221; designs consider secondary. When phrased like that, I personally, am all for the bottom of it!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sam Martin</title>
		<link>http://ashutoshmehra.net/blog/2009/06/kernighan-plauger-programming-style/comment-page-1/#comment-992</link>
		<dc:creator>Sam Martin</dc:creator>
		<pubDate>Fri, 10 Jul 2009 11:41:10 +0000</pubDate>
		<guid isPermaLink="false">http://ashutoshmehra.net/blog/?p=556#comment-992</guid>
		<description>I think it&#039;s interesting that most of the extracts lean towards following a functional style of programming over an imperative style. Does the book make any explicit mention of functional programming languages?

Most points sound pretty decent and uncontroversial. I&#039;m not sure about the top-down one though! This kind of approach works a lot of time, but not all the time. Sometimes it&#039;s actually better to build things bottom up, or do a mix of both. I think it depends more on what the problem is.

Thanks,
Sam</description>
		<content:encoded><![CDATA[<p>I think it&#8217;s interesting that most of the extracts lean towards following a functional style of programming over an imperative style. Does the book make any explicit mention of functional programming languages?</p>
<p>Most points sound pretty decent and uncontroversial. I&#8217;m not sure about the top-down one though! This kind of approach works a lot of time, but not all the time. Sometimes it&#8217;s actually better to build things bottom up, or do a mix of both. I think it depends more on what the problem is.</p>
<p>Thanks,<br />
Sam</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ashutosh</title>
		<link>http://ashutoshmehra.net/blog/2009/06/kernighan-plauger-programming-style/comment-page-1/#comment-989</link>
		<dc:creator>Ashutosh</dc:creator>
		<pubDate>Fri, 03 Jul 2009 17:54:00 +0000</pubDate>
		<guid isPermaLink="false">http://ashutoshmehra.net/blog/?p=556#comment-989</guid>
		<description>Thanks for the comment, Radu. 

Yes, I remember flipping through that book some years ago -- it did have a similar flavor. 

Kernighan&#039;s books are still awesome if only because they are short, sweet, to the point, and, of course, still relevant -- one small reason I prefer them over, say, &lt;i&gt;&lt;a href=&quot;http://www.amazon.com/gp/product/0735619670?ie=UTF8&amp;tag=ashmehblo-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0735619670&quot; rel=&quot;nofollow&quot;&gt;Code Complete&lt;/a&gt;&lt;/i&gt;.

&lt;i&gt;Code Complete&lt;/i&gt; too, is highly acclaimed, on similar lines, and more current. But it&#039;s a much larger work (~250 vs. ~1000 pages), and studying it would take much more than a week (roughly the time I took to finish &lt;i&gt;Programming Style&lt;/i&gt;).</description>
		<content:encoded><![CDATA[<p>Thanks for the comment, Radu. </p>
<p>Yes, I remember flipping through that book some years ago &#8212; it did have a similar flavor. </p>
<p>Kernighan&#8217;s books are still awesome if only because they are short, sweet, to the point, and, of course, still relevant &#8212; one small reason I prefer them over, say, <i><a href="http://www.amazon.com/gp/product/0735619670?ie=UTF8&#038;tag=ashmehblo-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0735619670" rel="nofollow">Code Complete</a></i>.</p>
<p><i>Code Complete</i> too, is highly acclaimed, on similar lines, and more current. But it&#8217;s a much larger work (~250 vs. ~1000 pages), and studying it would take much more than a week (roughly the time I took to finish <i>Programming Style</i>).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Radu Grigore</title>
		<link>http://ashutoshmehra.net/blog/2009/06/kernighan-plauger-programming-style/comment-page-1/#comment-988</link>
		<dc:creator>Radu Grigore</dc:creator>
		<pubDate>Fri, 03 Jul 2009 12:22:30 +0000</pubDate>
		<guid isPermaLink="false">http://ashutoshmehra.net/blog/?p=556#comment-988</guid>
		<description>You might also enjoy &lt;a href=&quot;http://www.google.com/search?q=the+practice+of+programming&quot; rel=&quot;nofollow&quot;&gt;&lt;i&gt;The Practice of Programming&lt;/i&gt;&lt;/a&gt;. I didn&#039;t read &lt;i&gt;Programming Style&lt;/i&gt; but, from what you say, it has a similar style.</description>
		<content:encoded><![CDATA[<p>You might also enjoy <a href="http://www.google.com/search?q=the+practice+of+programming" rel="nofollow"><i>The Practice of Programming</i></a>. I didn&#8217;t read <i>Programming Style</i> but, from what you say, it has a similar style.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ashutosh</title>
		<link>http://ashutoshmehra.net/blog/2009/06/kernighan-plauger-programming-style/comment-page-1/#comment-976</link>
		<dc:creator>Ashutosh</dc:creator>
		<pubDate>Thu, 18 Jun 2009 08:17:51 +0000</pubDate>
		<guid isPermaLink="false">http://ashutoshmehra.net/blog/?p=556#comment-976</guid>
		<description>&lt;a href=&quot;#comment-975&quot; rel=&quot;nofollow&quot;&gt;@roshan mathews&lt;/a&gt;: I&#039;ve had this book for many years now; don&#039;t know where I bought it from -- perhaps from some senior in college at a dirt cheap price. I&#039;ve tonnes of books lying around that I plan to read some day. I even have a copy of the other K&amp;P book &lt;i&gt;&lt;a href=&quot;http://www.amazon.com/Software-Tools-Brian-W-Kernighan/dp/020103669X&quot; rel=&quot;nofollow&quot;&gt;Software Tools&lt;/a&gt;&lt;/i&gt; that I plan to read some day.

As for K&amp;P&#039;s Style book, &lt;a href=&quot;http://www.amazon.com/gp/product/0070342075&quot; rel=&quot;nofollow&quot;&gt;amazon.com&lt;/a&gt; and &lt;a href=&quot;http://www.alibris.com/booksearch?qwork=2001651&amp;matches=16&amp;wquery=elements+of+programming+style&amp;cm_sp=works*listing*title&quot; rel=&quot;nofollow&quot;&gt;alibris&lt;/a&gt; appear to be selling it for ~$10 second hand; and considering that it&#039;s about the price of an equally important work, &lt;i&gt;&lt;a href=&quot;http://www.amazon.com/Zombie-Survival-Guide-Complete-Protection/dp/1400049628/&quot; rel=&quot;nofollow&quot;&gt;The Zombie Survival Guide&lt;/a&gt;&lt;/i&gt;, I think it&#039;s a good bargain!

And yes, the ACM Classic Book Series has left this book out, and a few others I wish to browse through: Yourdon&#039;s &lt;i&gt;Classics in Software Engineering&lt;/i&gt; and Iverson&#039;s &lt;i&gt;APL&lt;/i&gt;.</description>
		<content:encoded><![CDATA[<p><a href="#comment-975" rel="nofollow">@roshan mathews</a>: I&#8217;ve had this book for many years now; don&#8217;t know where I bought it from &#8212; perhaps from some senior in college at a dirt cheap price. I&#8217;ve tonnes of books lying around that I plan to read some day. I even have a copy of the other K&#038;P book <i><a href="http://www.amazon.com/Software-Tools-Brian-W-Kernighan/dp/020103669X" rel="nofollow">Software Tools</a></i> that I plan to read some day.</p>
<p>As for K&#038;P&#8217;s Style book, <a href="http://www.amazon.com/gp/product/0070342075" rel="nofollow">amazon.com</a> and <a href="http://www.alibris.com/booksearch?qwork=2001651&#038;matches=16&#038;wquery=elements+of+programming+style&#038;cm_sp=works*listing*title" rel="nofollow">alibris</a> appear to be selling it for ~$10 second hand; and considering that it&#8217;s about the price of an equally important work, <i><a href="http://www.amazon.com/Zombie-Survival-Guide-Complete-Protection/dp/1400049628/" rel="nofollow">The Zombie Survival Guide</a></i>, I think it&#8217;s a good bargain!</p>
<p>And yes, the ACM Classic Book Series has left this book out, and a few others I wish to browse through: Yourdon&#8217;s <i>Classics in Software Engineering</i> and Iverson&#8217;s <i>APL</i>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: roshan mathews</title>
		<link>http://ashutoshmehra.net/blog/2009/06/kernighan-plauger-programming-style/comment-page-1/#comment-975</link>
		<dc:creator>roshan mathews</dc:creator>
		<pubDate>Thu, 18 Jun 2009 04:14:14 +0000</pubDate>
		<guid isPermaLink="false">http://ashutoshmehra.net/blog/?p=556#comment-975</guid>
		<description>Where did you get the book?  I&#039;ve been waiting for the pdf to come to the ACM Classic Books page ...</description>
		<content:encoded><![CDATA[<p>Where did you get the book?  I&#8217;ve been waiting for the pdf to come to the ACM Classic Books page &#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>
