<?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"
	>
<channel>
	<title>Comments on: Does perfect code exist? (Abstractions, Part 1)</title>
	<atom:link href="http://thunk.org/tytso/blog/2007/11/18/does-perfect-code-exist-abstractions-part-1/feed/" rel="self" type="application/rss+xml" />
	<link>http://thunk.org/tytso/blog/2007/11/18/does-perfect-code-exist-abstractions-part-1/</link>
	<description>Musings about Open Source, Linux, and Life by Theodore Tso</description>
	<pubDate>Tue, 06 Jan 2009 13:46:50 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
		<item>
		<title>By: varza de vineri, pt. 11. &#171; a place in the dirt__</title>
		<link>http://thunk.org/tytso/blog/2007/11/18/does-perfect-code-exist-abstractions-part-1/#comment-230</link>
		<dc:creator>varza de vineri, pt. 11. &#171; a place in the dirt__</dc:creator>
		<pubDate>Fri, 23 Nov 2007 18:35:43 +0000</pubDate>
		<guid isPermaLink="false">http://thunk.org/tytso/blog/2007/11/18/does-perfect-code-exist-abstractions-part-1/#comment-230</guid>
		<description>[...] Îmi place mult post-ul ăsta. Îmi place că se poate aplica în multe [...]</description>
		<content:encoded><![CDATA[<p>[...] Îmi place mult post-ul ăsta. Îmi place că se poate aplica în multe [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sp3w</title>
		<link>http://thunk.org/tytso/blog/2007/11/18/does-perfect-code-exist-abstractions-part-1/#comment-229</link>
		<dc:creator>Sp3w</dc:creator>
		<pubDate>Fri, 23 Nov 2007 17:38:19 +0000</pubDate>
		<guid isPermaLink="false">http://thunk.org/tytso/blog/2007/11/18/does-perfect-code-exist-abstractions-part-1/#comment-229</guid>
		<description>[...] On perfect code Certainly no matter what its warts, the Unix/Posix interface has proven the test of time, and it has been responsible for the success of many a company and many billions of dollars of market capitalization. But is this the same as perfect code? [...]</description>
		<content:encoded><![CDATA[<p>[...] On perfect code Certainly no matter what its warts, the Unix/Posix interface has proven the test of time, and it has been responsible for the success of many a company and many billions of dollars of market capitalization. But is this the same as perfect code? [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Seo Sanghyeon</title>
		<link>http://thunk.org/tytso/blog/2007/11/18/does-perfect-code-exist-abstractions-part-1/#comment-222</link>
		<dc:creator>Seo Sanghyeon</dc:creator>
		<pubDate>Wed, 21 Nov 2007 04:09:48 +0000</pubDate>
		<guid isPermaLink="false">http://thunk.org/tytso/blog/2007/11/18/does-perfect-code-exist-abstractions-part-1/#comment-222</guid>
		<description>I think something like GMP(adding and multiplying big integers) can be made perfect, or as perfect as possible. GMP is certainly not a trivial software -- it is actually incredibly complex. But "it sediments into the information infrastructure" indeed. Witness that GCC 4.3 requires GMP to build.</description>
		<content:encoded><![CDATA[<p>I think something like GMP(adding and multiplying big integers) can be made perfect, or as perfect as possible. GMP is certainly not a trivial software &#8212; it is actually incredibly complex. But &#8220;it sediments into the information infrastructure&#8221; indeed. Witness that GCC 4.3 requires GMP to build.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tytso</title>
		<link>http://thunk.org/tytso/blog/2007/11/18/does-perfect-code-exist-abstractions-part-1/#comment-218</link>
		<dc:creator>tytso</dc:creator>
		<pubDate>Mon, 19 Nov 2007 22:31:53 +0000</pubDate>
		<guid isPermaLink="false">http://thunk.org/tytso/blog/2007/11/18/does-perfect-code-exist-abstractions-part-1/#comment-218</guid>
		<description>Bryan,
The problem I have with "correct" is that its definition is still extremely squishy and dependent on an individuals needs.  When you say that code "faults aside" that has become bedrock is correct, if those faults causes special headaches to implementors, or if deployed code which relies on ambiguities in the interface specification, such that it can't be changed, they might take exception to the description of the code or the interface as "correct".

As far as interval timers are concerned, this is a great example of what I am talking about.   The mere fact that you have cyclic interrupts means something is non-ideal from a power-savings point of view; so if the cyclic system is being used at all, something is almost certainly using more power than it should.  You might argue that it can't go away because an interface (BSD and/or POSIX interval timers) promises that functionality will exist, but that's the point.   What if the interface is busted, or shouldn't exist, or should be used extremely rarely?  I can think if a few examples where perfectly exact interval timers are needed --- for example, for real-time data collection applications, and servo control --- but most of the time, applications don't need precise interval timers.  Yet they may very well end up using that particular interface because nothing better existed at the time.

So to fix these sorts of problems, sometimes you have to change or augment interfaces that had been previously thought of being bedrock.   Sometimes it's not enough to assume that a particular interface is a given, and only try to implement innovations underneath such an interface; instead, you have to somehow innovate around, over, or through a particular interface/abstraction.   And yes, sometimes that means trying to find all of the users of that interface, and convincing them to change how they use it.</description>
		<content:encoded><![CDATA[<p>Bryan,<br />
The problem I have with &#8220;correct&#8221; is that its definition is still extremely squishy and dependent on an individuals needs.  When you say that code &#8220;faults aside&#8221; that has become bedrock is correct, if those faults causes special headaches to implementors, or if deployed code which relies on ambiguities in the interface specification, such that it can&#8217;t be changed, they might take exception to the description of the code or the interface as &#8220;correct&#8221;.</p>
<p>As far as interval timers are concerned, this is a great example of what I am talking about.   The mere fact that you have cyclic interrupts means something is non-ideal from a power-savings point of view; so if the cyclic system is being used at all, something is almost certainly using more power than it should.  You might argue that it can&#8217;t go away because an interface (BSD and/or POSIX interval timers) promises that functionality will exist, but that&#8217;s the point.   What if the interface is busted, or shouldn&#8217;t exist, or should be used extremely rarely?  I can think if a few examples where perfectly exact interval timers are needed &#8212; for example, for real-time data collection applications, and servo control &#8212; but most of the time, applications don&#8217;t need precise interval timers.  Yet they may very well end up using that particular interface because nothing better existed at the time.</p>
<p>So to fix these sorts of problems, sometimes you have to change or augment interfaces that had been previously thought of being bedrock.   Sometimes it&#8217;s not enough to assume that a particular interface is a given, and only try to implement innovations underneath such an interface; instead, you have to somehow innovate around, over, or through a particular interface/abstraction.   And yes, sometimes that means trying to find all of the users of that interface, and convincing them to change how they use it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bryan Cantrill</title>
		<link>http://thunk.org/tytso/blog/2007/11/18/does-perfect-code-exist-abstractions-part-1/#comment-217</link>
		<dc:creator>Bryan Cantrill</dc:creator>
		<pubDate>Mon, 19 Nov 2007 21:30:28 +0000</pubDate>
		<guid isPermaLink="false">http://thunk.org/tytso/blog/2007/11/18/does-perfect-code-exist-abstractions-part-1/#comment-217</guid>
		<description>I'm not conflating code and interface, rather my point was that the sedimentation of interface often allows for new latitudes of innovation in terms of the code (because one no longer has to worry about getting the abstractions right -- one can just focus on innovating beneath them).  And again, if it makes it easier, don't think about perfect code -- think about correct code.  Much of that "less-than-perfect" code that you describe as becoming bedrock is -- other faults aside -- correct.

In terms of the relevance to software engineering in-the-large:  remember, I'm not maintaining that deep software engineering is representative of all of software engineering, but rather that the Chandler-esque cock-ups are themselves but one facet of our craft -- and not necessarily the most instructive facet.

Finally, as for cyclics, a little contamination would probably do you some good. ;) As John Levon mentioned, the cyclic subsystem is entirely deadline scheduled; if there are no cyclics, there is no interrupt -- there is nothing about its design or implementation that is mutually exclusive with the kind of "radical" power savings that you describe.  (As background, the design center for the subsystem was to allow arbitrary resolution interval timers, a must-have feature when developing a real-time system. Solaris is used as the basis for quite a few such systems, especially in the defense and telecommunications sectors.)

But all of this serves to remind me that I would have been better off pointing to some subset of the tens-of-thousands of lines of DTrace implementation, for which there exists no Linux analogue to confuse matters. ;)</description>
		<content:encoded><![CDATA[<p>I&#8217;m not conflating code and interface, rather my point was that the sedimentation of interface often allows for new latitudes of innovation in terms of the code (because one no longer has to worry about getting the abstractions right &#8212; one can just focus on innovating beneath them).  And again, if it makes it easier, don&#8217;t think about perfect code &#8212; think about correct code.  Much of that &#8220;less-than-perfect&#8221; code that you describe as becoming bedrock is &#8212; other faults aside &#8212; correct.</p>
<p>In terms of the relevance to software engineering in-the-large:  remember, I&#8217;m not maintaining that deep software engineering is representative of all of software engineering, but rather that the Chandler-esque cock-ups are themselves but one facet of our craft &#8212; and not necessarily the most instructive facet.</p>
<p>Finally, as for cyclics, a little contamination would probably do you some good. <img src='http://thunk.org/tytso/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> As John Levon mentioned, the cyclic subsystem is entirely deadline scheduled; if there are no cyclics, there is no interrupt &#8212; there is nothing about its design or implementation that is mutually exclusive with the kind of &#8220;radical&#8221; power savings that you describe.  (As background, the design center for the subsystem was to allow arbitrary resolution interval timers, a must-have feature when developing a real-time system. Solaris is used as the basis for quite a few such systems, especially in the defense and telecommunications sectors.)</p>
<p>But all of this serves to remind me that I would have been better off pointing to some subset of the tens-of-thousands of lines of DTrace implementation, for which there exists no Linux analogue to confuse matters. <img src='http://thunk.org/tytso/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tytso</title>
		<link>http://thunk.org/tytso/blog/2007/11/18/does-perfect-code-exist-abstractions-part-1/#comment-216</link>
		<dc:creator>tytso</dc:creator>
		<pubDate>Mon, 19 Nov 2007 20:09:36 +0000</pubDate>
		<guid isPermaLink="false">http://thunk.org/tytso/blog/2007/11/18/does-perfect-code-exist-abstractions-part-1/#comment-216</guid>
		<description>Bryan,
I agree that "perfect" probably caused red flags to fly, but "correct" has similar problems in that its meaning can't be bound until you specify "the set of requirements the code is meant to meet".   The bigger problem in your blog entry which I tried to call to call out is that you conflated interfaces and the code which implement them --- and  the presumption it is necessary for them to be perfect in order for them to become bedrock.  I think we can point out multiple examples where less-than-perfect code and interfaces have become the bedrock on which vast amounts of code and functionality have been built.  

Furthermore, while my passion is, like yours, involves making the portions of the bedrock that I am responsible as seismically stable as possible, I don't think it really helps solve the general problem of complex software engineering at the scale of Chandler, Lotus Notes, Microsoft Office, Sun's Java System Application Server, Tivoli Total Storage Productive Center, and other Very Large Products which include complex UI's --- something which those of us who do OS engineering generally don't have to worry about much.   

Finally, while I'm not particularly interested in getting contaminated, I will argue that if cyclic's job is to run code on some regular period, such as the HZ heartbeat timer code, this is functionality which is &lt;i&gt;never&lt;/i&gt; a good idea if you are truly interested in power saving.   In order to get there, code should be woken up when it needs to be, and ideally batched with other code that needs to be woken up at roughly the same time within the permissions given to the timer subsystem regarding accuracy requirements.  There should be no reason why a low-level regular heartbeat callback should be called on a system which is trying to save power in a truly radical way.  (What?   You have a blinking cursor?  That should be turned off, or if you must have blinking cursor, it should blink at the same time as all other blinking UI elements.   The former is still preferable, though!  :-)</description>
		<content:encoded><![CDATA[<p>Bryan,<br />
I agree that &#8220;perfect&#8221; probably caused red flags to fly, but &#8220;correct&#8221; has similar problems in that its meaning can&#8217;t be bound until you specify &#8220;the set of requirements the code is meant to meet&#8221;.   The bigger problem in your blog entry which I tried to call to call out is that you conflated interfaces and the code which implement them &#8212; and  the presumption it is necessary for them to be perfect in order for them to become bedrock.  I think we can point out multiple examples where less-than-perfect code and interfaces have become the bedrock on which vast amounts of code and functionality have been built.  </p>
<p>Furthermore, while my passion is, like yours, involves making the portions of the bedrock that I am responsible as seismically stable as possible, I don&#8217;t think it really helps solve the general problem of complex software engineering at the scale of Chandler, Lotus Notes, Microsoft Office, Sun&#8217;s Java System Application Server, Tivoli Total Storage Productive Center, and other Very Large Products which include complex UI&#8217;s &#8212; something which those of us who do OS engineering generally don&#8217;t have to worry about much.   </p>
<p>Finally, while I&#8217;m not particularly interested in getting contaminated, I will argue that if cyclic&#8217;s job is to run code on some regular period, such as the HZ heartbeat timer code, this is functionality which is <i>never</i> a good idea if you are truly interested in power saving.   In order to get there, code should be woken up when it needs to be, and ideally batched with other code that needs to be woken up at roughly the same time within the permissions given to the timer subsystem regarding accuracy requirements.  There should be no reason why a low-level regular heartbeat callback should be called on a system which is trying to save power in a truly radical way.  (What?   You have a blinking cursor?  That should be turned off, or if you must have blinking cursor, it should blink at the same time as all other blinking UI elements.   The former is still preferable, though!  <img src='http://thunk.org/tytso/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bryan Cantrill</title>
		<link>http://thunk.org/tytso/blog/2007/11/18/does-perfect-code-exist-abstractions-part-1/#comment-215</link>
		<dc:creator>Bryan Cantrill</dc:creator>
		<pubDate>Mon, 19 Nov 2007 19:12:51 +0000</pubDate>
		<guid isPermaLink="false">http://thunk.org/tytso/blog/2007/11/18/does-perfect-code-exist-abstractions-part-1/#comment-215</guid>
		<description>I think the word "perfect" may be being problematic here -- I was seeking to use the word to rhetorically sharpen a point, not to boast about work that I had done or to proclaim my own infallibility.  For the point that I was trying to make -- and specifically for the code that I referenced -- I think "correct" is the much more apt term.  The cyclic subsystem is certainly not perfect in a broad never-can-be-improved sense, but I do believe that it is largely correct.  That said, I also take issue with the specific issues that you appear to think that you have with its design and implementation, but those issues are orthogonal to my point about correctness.  And besides, resolving them would require me to -- in your parlance -- "contaminate" you, and we certainly don't want that! ;)</description>
		<content:encoded><![CDATA[<p>I think the word &#8220;perfect&#8221; may be being problematic here &#8212; I was seeking to use the word to rhetorically sharpen a point, not to boast about work that I had done or to proclaim my own infallibility.  For the point that I was trying to make &#8212; and specifically for the code that I referenced &#8212; I think &#8220;correct&#8221; is the much more apt term.  The cyclic subsystem is certainly not perfect in a broad never-can-be-improved sense, but I do believe that it is largely correct.  That said, I also take issue with the specific issues that you appear to think that you have with its design and implementation, but those issues are orthogonal to my point about correctness.  And besides, resolving them would require me to &#8212; in your parlance &#8212; &#8220;contaminate&#8221; you, and we certainly don&#8217;t want that! <img src='http://thunk.org/tytso/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tac-Tics</title>
		<link>http://thunk.org/tytso/blog/2007/11/18/does-perfect-code-exist-abstractions-part-1/#comment-214</link>
		<dc:creator>Tac-Tics</dc:creator>
		<pubDate>Mon, 19 Nov 2007 16:34:33 +0000</pubDate>
		<guid isPermaLink="false">http://thunk.org/tytso/blog/2007/11/18/does-perfect-code-exist-abstractions-part-1/#comment-214</guid>
		<description>If there is perfect code, I believe it is demonstrated in a subset of Haskell's Prelude. While people's opinion's on Haskell overall vary greatly among different groups, I believe the basic function definitions for the language are the cleanest, most math-worthy definitions we will ever have of them. They are so perfect they almost deserve to be etched into a giant stone tablet somewhere ;-)

(List append)
[] ++ ys = ys
(x:xs) ++ ys = x : (xs ++ ys)

map f [] = []
map f (x:xs) = f x : xs

sum [] = 0
sum (x:xs) = x + sum xs</description>
		<content:encoded><![CDATA[<p>If there is perfect code, I believe it is demonstrated in a subset of Haskell&#8217;s Prelude. While people&#8217;s opinion&#8217;s on Haskell overall vary greatly among different groups, I believe the basic function definitions for the language are the cleanest, most math-worthy definitions we will ever have of them. They are so perfect they almost deserve to be etched into a giant stone tablet somewhere <img src='http://thunk.org/tytso/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>(List append)<br />
[] ++ ys = ys<br />
(x:xs) ++ ys = x : (xs ++ ys)</p>
<p>map f [] = []<br />
map f (x:xs) = f x : xs</p>
<p>sum [] = 0<br />
sum (x:xs) = x + sum xs</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tytso</title>
		<link>http://thunk.org/tytso/blog/2007/11/18/does-perfect-code-exist-abstractions-part-1/#comment-213</link>
		<dc:creator>tytso</dc:creator>
		<pubDate>Mon, 19 Nov 2007 13:59:32 +0000</pubDate>
		<guid isPermaLink="false">http://thunk.org/tytso/blog/2007/11/18/does-perfect-code-exist-abstractions-part-1/#comment-213</guid>
		<description>The probablem is that any use of periodics are a really bad idea from a power management standpoint --- whether it is a 100 times a second or once every two seconds.  And if it is once every two seconds, then accuracy makes a huge difference, since normally accuracy down to milliseconds isn't important at the second granularity scale, and it does a &lt;b&gt;huge&lt;/b&gt; difference to wake up the CPU once and do all of your "once a second" housekeeping tasks than to wake up a dozen times to do the same amount of housekeeping.</description>
		<content:encoded><![CDATA[<p>The probablem is that any use of periodics are a really bad idea from a power management standpoint &#8212; whether it is a 100 times a second or once every two seconds.  And if it is once every two seconds, then accuracy makes a huge difference, since normally accuracy down to milliseconds isn&#8217;t important at the second granularity scale, and it does a <b>huge</b> difference to wake up the CPU once and do all of your &#8220;once a second&#8221; housekeeping tasks than to wake up a dozen times to do the same amount of housekeeping.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Levon</title>
		<link>http://thunk.org/tytso/blog/2007/11/18/does-perfect-code-exist-abstractions-part-1/#comment-212</link>
		<dc:creator>John Levon</dc:creator>
		<pubDate>Mon, 19 Nov 2007 07:57:29 +0000</pubDate>
		<guid isPermaLink="false">http://thunk.org/tytso/blog/2007/11/18/does-perfect-code-exist-abstractions-part-1/#comment-212</guid>
		<description>You picked an unfortunate example: the cyclics sub-system is deadline-based and only wakes up when requested. It's currently
/used/ by the heartbeat HZ timer, but that's something outside
of cyclic.c itself, and so isn't a problem with the cyclics code
(indeed, fixing that and other non-tickless usages should be do-able
without changing the cyclic code at all). I don't believe that the
"accuracy" part is really worth it, you can just choose between
normal periodics (most cases) or real-time.</description>
		<content:encoded><![CDATA[<p>You picked an unfortunate example: the cyclics sub-system is deadline-based and only wakes up when requested. It&#8217;s currently<br />
/used/ by the heartbeat HZ timer, but that&#8217;s something outside<br />
of cyclic.c itself, and so isn&#8217;t a problem with the cyclics code<br />
(indeed, fixing that and other non-tickless usages should be do-able<br />
without changing the cyclic code at all). I don&#8217;t believe that the<br />
&#8220;accuracy&#8221; part is really worth it, you can just choose between<br />
normal periodics (most cases) or real-time.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
