<?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>Brooks Moses: Notes on Divergent Simulations &#187; Programming and People</title>
	<atom:link href="http://notes.dpdx.net/category/programming-and-people/feed/" rel="self" type="application/rss+xml" />
	<link>http://notes.dpdx.net</link>
	<description>Fluid Dynamics, Computer Simulations, and Assorted Tinkering</description>
	<lastBuildDate>Tue, 06 May 2008 05:23:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>An interesting little phenomenon</title>
		<link>http://notes.dpdx.net/2008/04/10/an-interesting-little-phenomenon/</link>
		<comments>http://notes.dpdx.net/2008/04/10/an-interesting-little-phenomenon/#comments</comments>
		<pubDate>Thu, 10 Apr 2008 21:48:27 +0000</pubDate>
		<dc:creator>Brooks</dc:creator>
				<category><![CDATA[Programming and People]]></category>

		<guid isPermaLink="false">http://notes.dpdx.net/2008/04/10/an-interesting-little-phenomenon/</guid>
		<description><![CDATA[So, earlier today, Jeff Atwood wrote a rather interesting post about people who aren&#8217;t willing to pay money for software.  And in there, he made this comment:
It&#8217;s tempting to ascribe this to the &#8220;cult of no-pay&#8221;, programmers and users who simply won&#8217;t pay for software no matter how good it is, or how inexpensive [...]]]></description>
			<content:encoded><![CDATA[<p>So, earlier today, <a href="http://www.codinghorror.com/blog/">Jeff Atwood</a> wrote a rather interesting <a href="http://www.codinghorror.com/blog/archives/001097.html">post about people who aren&#8217;t willing to pay money for software</a>.  And in there, he made this comment:<br />
<blockquote>It&#8217;s tempting to ascribe this to the &#8220;cult of no-pay&#8221;, programmers and users who simply <b>won&#8217;t pay for software</b> no matter how good it is, or how inexpensive it may be. These people used to be called <i>pirates</i>. Now they&#8217;re <i>open source enthusiasts</i>.</p></blockquote>
<p>And there&#8217;s been the predictable outcry of <a href="http://avinashv.net/2008/04/so-im-a-software-pirate/">blog</a> <a href="http://perlbuzz.com/2008/04/open-source-is-not-piracy.html">posts</a> reading that as saying that open source enthusiasts are pirates, and saying things like <a href="http://perlbuzz.com/2008/04/open-source-is-not-piracy.html">this</a>:<br />
<blockquote>Jeff Atwood&#8217;s blog Coding Horror is one of my favorites. Until yesterday, I&#8217;d been recommending it unreservedly. Jeff&#8217;s made a big stumble, and I hope he corrects it soon&#8230;.</p></blockquote>
<p>Right.  First off, anyone who&#8217;s read Jeff&#8217;s blog and is halfway observant knows a couple of things about him.  He&#8217;s intelligent, and he&#8217;s outspoken about his opinions.  If he wanted to say that open-source enthusiasts were the same as pirates, he would come right out and say it, and give you several paragraphs of reasons why he thought that.  He wouldn&#8217;t just imply it in a throwaway sentence like that.  So it ought to be obvious to any reasonable reader that that&#8217;s not what he intended, regardless of how he worded it.</p>
<p>More than that, though, I find the reaction of &#8220;I can no longer unreservedly recommend this blog&#8221; to be quite interesting.  Suppose that Jeff <i>did</i> intend to say that open-source enthusiasts were pirates?  I don&#8217;t agree with that, obviously, but so what?  I don&#8217;t think I&#8217;ve ever read a blog that I completely agree with; that&#8217;s what makes conversation worthwhile, and if he has a good argument to back it up, it&#8217;s probably worth reading even if I think it&#8217;s erroneous.  To me, what makes a blog worth recommending is when it presents intelligent arguments based on reasonable facts, in a way that I find interesting and thought-provoking and on subjects that I think are worth reading about.  Making a &#8220;stumble&#8221; doesn&#8217;t change any of that.</p>
]]></content:encoded>
			<wfw:commentRss>http://notes.dpdx.net/2008/04/10/an-interesting-little-phenomenon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What would an expert want with recipes?</title>
		<link>http://notes.dpdx.net/2006/05/23/what-would-an-expert-want-with-recipes/</link>
		<comments>http://notes.dpdx.net/2006/05/23/what-would-an-expert-want-with-recipes/#comments</comments>
		<pubDate>Tue, 23 May 2006 21:25:24 +0000</pubDate>
		<dc:creator>Brooks</dc:creator>
				<category><![CDATA[Programming and People]]></category>

		<guid isPermaLink="false">http://notes.dpdx.net/2006/05/23/what-would-an-expert-want-with-recipes/</guid>
		<description><![CDATA[Jeff Atwood makes the point that although experts generally don&#8217;t follow recipes (such as &#8220;best practices&#8221;) literally, the recipes are still valuable:

The idea that a recipe (eg, a best practice, a methodology, or a maturity model) is completely worthless is just as wrongheaded as the idea that everything should be based on a strict recipe. [...]]]></description>
			<content:encoded><![CDATA[<p>Jeff Atwood <a href="http://www.codinghorror.com/blog/archives/000594.html">makes the point</a> that although experts generally don&#8217;t follow recipes (such as &#8220;best practices&#8221;) literally, the recipes are still valuable:</p>
<blockquote><p>
The idea that a recipe (eg, a best practice, a methodology, or a maturity model) is completely worthless is just as wrongheaded as the idea that everything should be based on a strict recipe. In other words, even an expert chef may occasionally find it helpful to refer to a recipe card. </p>
<p>There&#8217;s no reason these two models can&#8217;t coexist. You should always start with the common denominator recipe, of course, but you may want to provide some alternative guidelines and ideas for those cooks who have outgrown traditional recipes, too.</p></blockquote>
<p>I strongly agree with his general point, but I think that &#8220;guidelines and ideas&#8221; are the wrong sort of thing to include.</p>
<p>To take the metaphor literally, for some things, I&#8217;m a <a href="http://www.codinghorror.com/blog/archives/000203.html">level 4</a> cook.  (Not necessarily an especially good one — it&#8217;s worth noting that these levels are not always parallel to the quality of the output!)  A particular example would be some coleslaw I made a couple of weeks ago, when I found myself in an ill-stocked kitchen with a cabbage, an empty stomach, and the <i>Joy of Cooking</i>.</p>
<p>The <i>Joy of Cooking</i> is a pretty good cookbook for this sort of thing, as it turns out.  It has a half-page discussion of what coleslaw is, without any recipes at all.  It turns out that pretty much the only common factor in slaw is that it has cabbage in it.  Everything else is variable.  (This was an important point; we had no mayonaisse, and the person I was cooking with insisted that coleslaw has to have mayo.)  It went on to describe, in loose terms, some of the common varieties.  I skimmed through those, and then went on to look at the actual recipes.  The standard recipe format is well-optimized for this sort of thing; there&#8217;s a list of ingredients at the top, separate from the instructions, making it very easy to skim to pull out specific bits of data such as the ratio of sugar to vinegar in a sugar-vinegar slaw.</p>
<p>After looking through the cookbook, I&#8217;d gleaned the following information: sugar and vinegar are a perfectly sufficient base for a slaw dressing, and it&#8217;s common to have them in X ratio, Y is a typical amount of salt, and Z, W, Q, and a dozen other things are some ideas for spices to put it.</p>
<p>Those, you may object, look exactly like &#8220;guidelines and ideas&#8221;.  So, why am I objecting to including guidelines and ideas for experts in the recipe?  The same reason that specific instructions are wrong for experts: They are <i>processed</i> information, and the definition of &#8220;expert&#8221; in this context is someone who does their own information processing.  In my case, when I read the recipes, I was mining them for bits of information.  Any processing that complicates that information-mining is a detriment, not a benefit.</p>
<p>And so, when writing recipes to be useful beyond basic instructions, the thing to include is facts.  Not a guideline of &#8220;this squash should be cooked for 20 minutes&#8221;, but the fact of &#8220;if you cook this squash for more than 25 minutes it will be mushy and begin to lose flavor.&#8221;  Not the idea of, &#8220;You could use peaches in this,&#8221; but the fact of &#8220;Peaches are also common in this.&#8221;  The guidelines and ideas are certainly useful because they contain facts, but the parts that make them &#8220;guidelines&#8221; and &#8220;ideas&#8221; rather than bare facts rarely are.  Often the process of distilling the fact into a guideline or idea loses useful information, too; suppose I wanted mushy squash, or wanted an uncommon alteration?</p>
]]></content:encoded>
			<wfw:commentRss>http://notes.dpdx.net/2006/05/23/what-would-an-expert-want-with-recipes/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Nerd Bravado, redux.</title>
		<link>http://notes.dpdx.net/2006/05/12/nerd-bravado-redux/</link>
		<comments>http://notes.dpdx.net/2006/05/12/nerd-bravado-redux/#comments</comments>
		<pubDate>Sat, 13 May 2006 06:30:40 +0000</pubDate>
		<dc:creator>Brooks</dc:creator>
				<category><![CDATA[Programming and People]]></category>

		<guid isPermaLink="false">http://notes.dpdx.net/2006/05/12/nerd-bravado-redux/</guid>
		<description><![CDATA[I was reading Kristin Abkemeier&#8217;s post on what it feels like to be a &#8220;geek girl&#8221;, and she linked to Matt McIrvin&#8217;s post about Nerd Bravado, which is the claim (originally made by an anonymous poster on yet a third blog post that I haven&#8217;t read) that in order to have any cred as an [...]]]></description>
			<content:encoded><![CDATA[<p>I was reading <a href="http://radioactive-banana.com/blog/2006/03/08/what-it-feels-like-for-a-geek-girl/">Kristin Abkemeier&#8217;s post on what it feels like to be a &#8220;geek girl&#8221;</a>, and she linked to <a href="http://mmcirvin.livejournal.com/300531.html">Matt McIrvin&#8217;s post about Nerd Bravado</a>, which is the claim (originally made by an anonymous poster on yet a third blog post that I haven&#8217;t read) that in order to have any cred as an engineer, one has to at least once solve a problem in the manner of sitting down and working on it for 20 or 30 hours of continuous independent work, because there are some problems that can&#8217;t be solved any other way.  (To be clear, that&#8217;s a claim that Matt was describing in order to disagree with it.)</p>
<p>I&#8217;m going to claim some authority in talking about this, because I&#8217;ve done that — and it wasn&#8217;t just 20 or 30 hours, either.  A year ago, I thought that there was some chance that I could finish my dissertation by the end of the academic year if I got a certain set of simulations done, which required taking a computer program that was currently held together by Duck-brand Fortran Tape, and turning the structurally unsound mass of the core algorithms into a well-oiled robust, solid, machine that would do what I told it.  I had two weeks in which to either accomplish it or give up.</p>
<p>So, I sat down on Monday to start working on it, and for all practical purposes, I worked on it straight through until Wednesday of the following week.</p>
<p>This is the first flaw of the Nerd Bravado claim.  Hyperfocus doesn&#8217;t care if you sleep and eat and take a shower.  You can think while you&#8217;re eating.  Your brain keeps working on things when you sleep, and if you think about a problem when you go to bed and when you get up in the morning, you&#8217;ll often find that some tricky bit of it has become a lot clearer in the interim.  You don&#8217;t have to sit for 25 hours straight to get the benefits.</p>
<p>That&#8217;s where the benefit of this style of working is, insofar as there is one: Hyperfocus.  After a dozen or so hours into this project, I was so focused on it that I couldn&#8217;t really think about anything else — even if I tried, the problems in the code would keep distracting me back to the task.  And, because I&#8217;d pretty much emptied everything else from short-term memory, quite a lot of stuff about the code could fit in there — enough to contain all the complicated interweavings of how the code all fit together.  I could look at the results and see where the problems were coming from and what bits of subroutines wove together to create the particular effect that was happening, and I knew, without having to look, where to prod the program to change it, and when I prodded it, it changed.  It&#8217;s a heady feeling.</p>
<p>I think that&#8217;s what the appeal of Nerd Bravado is, really.  It&#8217;s like spice, from Dune.  Get a bit of it into your system, and the universe opens up before you and whirls at your beck and call, and you have tremendous power at your fingertips to poke exactly the right thing in exactly the right place.  But it&#8217;s also got downsides; do it a few too many times, and your eyeballs turn funny colors and it completely eats your life.</p>
<p>Now, I said I had two weeks to fix this program, and I stopped a week and a half in.  Do you think that means I finished early?  Hardly.  A week in, and I&#8217;d gotten all the easy bugs fixed and most of the complicated ones, and I&#8217;d started tangling with the algorithms at the core of it.  And they had a problem: The math that I was working with involved solving an equation where significant parts of both sides are multiplied by a factor that goes to zero.  Divide that out to solve it, and very small errors in one term become very big errors in the solution, and it stops being well-behaved.  There are ways around this, but they have to be designed into the algorithm from the start, not bolted on later.  And by about Wednesday, it became quite clear that I was dealing with something that needed to be fixed from the ground up, and there was no way I could come close to that in the three days I had left.</p>
<p>This is the second flaw of the Nerd Bravado claim.  It doesn&#8217;t actually solve the real big problems.  Hyperfocus is a state of working on instincts, of having enough information actively in your brain that you don&#8217;t have to work through logic and deductive reasoning to know what the Right Thing To Do Now is.  And that&#8217;s great, if what you need to accomplish is something that&#8217;s a chain of consecutive steps, like debugging a convoluted program or working through a complicated mathematical derivation or even writing a new program that fits a general specification that you&#8217;ve already determined.</p>
<p>Real big problems aren&#8217;t like that.  Flash-of-insight problems aren&#8217;t like that — Einstein didn&#8217;t have his flash of insight about time dilation on the trolley because he&#8217;d been hyperfocusing on the problem for the past few days; he had it because he&#8217;d been rolling the problem around in his head for months.  (Or years; I don&#8217;t actually know that bit of his biography well enough to say for sure.)  And hard-work problems aren&#8217;t like that, either — writing a fixed version of my program isn&#8217;t going to work like that either, because it needs to be designed right from the ground up, and designing something right is a process that requires awareness of the outside world, and of a lot more than what fits in the hyperfocus.  Yes, there are the legends of the great designers who sit down and in one day lay out the basic lines of an airplane or a car engine that are more right than their less-great colleagues create with a committee and a month, and that comes from having tremendous amounts of knowledge in their heads, but that&#8217;s the sort of knowledge that gets there over years, not hours.</p>
<p>This brings me to the third flaw of the Nerd Bravado claim: It&#8217;s not, overall, worth doing.  When I&#8217;d finished my week-and-a-half of debugging, I was mentally exhausted.  I was a week behind on all of the minutiae of daily life, I was emotionally starved for interpersonal interactions, I&#8217;d barely talked to my wife about anything that mattered to her, and my brain felt thoroughly fried.  (My wife&#8217;s ironic laugh when I asked her if she remembered when I did this probably tells you all you need to know about what it was like from the outside.)  It took somewhere around a month before my work productivity was anywhere near normal again.  All totaled, I&#8217;d probably have accomplished as much if I&#8217;d simply worked at a reasonable pace for the month and two weeks, and I&#8217;m pretty sure the resulting solution would have been worth a bit more, as I&#8217;d have had the time to actually work out at least a first cut at a ground-up solution.</p>
<p>And, finally, the fourth flaw of the Nerd Bravado claim: the claim that &#8220;you must do it at least once to be a successful engineer &#8230; and to gain the respect of your peers&#8221; simply doesn&#8217;t hold true.  The result of this particular experience, for me, was that I had a nicely debugged program that solved the equations the wrong way and didn&#8217;t produce useful answers.  And all I learned from it was this: That style of working isn&#8217;t sustainable, and doesn&#8217;t lead to an enjoyable life, and I don&#8217;t want to do it again except in very small doses.  As for the respect of my peers — well, does this cause any of you to respect me any more?  No?  I didn&#8217;t think so.</p>
]]></content:encoded>
			<wfw:commentRss>http://notes.dpdx.net/2006/05/12/nerd-bravado-redux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Free-software licenses: requirements vs. requests.</title>
		<link>http://notes.dpdx.net/2006/04/24/free-software-licenses-and-obligations/</link>
		<comments>http://notes.dpdx.net/2006/04/24/free-software-licenses-and-obligations/#comments</comments>
		<pubDate>Tue, 25 Apr 2006 02:39:10 +0000</pubDate>
		<dc:creator>Brooks</dc:creator>
				<category><![CDATA[Programming and People]]></category>

		<guid isPermaLink="false">http://notes.dpdx.net/2006/04/24/free-software-licenses-and-obligations/</guid>
		<description><![CDATA[I&#8217;ve been thinking quite a lot about free software licenses lately, and how important it is to get them right.  A couple of recent events will serve to illustrate some of the important points:

The &#8220;listings&#8221; package for LaTeX is invaluable for including computer source code in a document.  It&#8217;s something like syntax highlighting [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been thinking quite a lot about free software licenses lately, and how important it is to get them right.  A couple of recent events will serve to illustrate some of the important points:</p>
<ul>
<li>The &#8220;listings&#8221; package for LaTeX is invaluable for including computer source code in a document.  It&#8217;s something like syntax highlighting in a source code editor, but for typeset output rather than on-screen, and very easily user-customizable.  Carsten Heinz spent almost a decade writing it and perfecting it, and it&#8217;s a marvel of intricate TeX programming — 218 pages of typeset user documentation and source code.  Then, about a year ago, Carsten disappeared.  As far as I know, nobody in the TeX community knows what happened to him; he simply stopped replying to email, and letters to his last known physical address just disappear.  As a result, the official version of the listings package has effectively been frozen for the last year, despite a couple of important bugfixes that have been informally circulating.  Luckily, this isn&#8217;t a permanent situation; it&#8217;s licensed under the LaTeX Project Public License, which provides a process by which the maintainership of the &#8220;official version&#8221; of a package can be transferred to someone else in such a case.
</li>
<li>In a blog post I was reading this morning (I&#8217;m leaving this vague so as not to point fingers excessively at only one example of a common problem), the author mentioned a general-purpose data structure that he had included in his open-source simulation code, and provided a link to the source file for the implementation.  Like many such implementations, it&#8217;s sufficiently general that it would be useful in many programs that I&#8217;m writing, and it&#8217;s a better implementation than I could come up with (and test!) in a day&#8217;s work.  However, there&#8217;s a problem: The license for this software package is not quite the same as any common software license, and it requires that its particular set of conditions and disclaimer be included in any redistribution.  Further, the license has the relatively common clause that any scientific publications which contain data resulting from use of the program must cite it.
</li>
</ul>
<p>I&#8217;ll start with the last item.  It&#8217;s completely reasonable that the author of a piece of scientific software would want to be cited when their work is used, so what&#8217;s wrong with putting that in the license?  <a href="http://www.gnu.org/philosophy/bsd.html">The answer is a lesson that should have been learned years ago.</a>  It only makes sense for cases where what&#8217;s being redistributed is pretty much the same as the original work.  Beyond the well-known problems described at that link (short form: someone else builds on it enough to merit citation and adds their paper, and after a few repeats of that it quickly becomes unweildy), there&#8217;s the problem of partial reuse: if I include this little data structure implementation in my program, according to the license I then have to cite their paper in all of mine, even though my work is in a quite unrelated field.  And so does anyone who uses my program.  While that might arguably be appropriate for an advertising clause, it&#8217;s not appropriate for scientific citations.</p>
<p>So, functionally, I pretty much can&#8217;t reuse their data structure in my own software, if I wish to do so under its published license.  That&#8217;s completely contrary to the spirit of free software; even though it&#8217;s open source and I can read it, the license prohibits me from simply copying it and reusing it unless I&#8217;m willing to agree to inappropriate terms.  This almost certainly isn&#8217;t the intent of the program&#8217;s author; he simply didn&#8217;t consider the possibility of someone reusing a small piece of his program when he decided how to license it.</p>
<p>In this case, there&#8217;s probably a simple solution.  If I want to use this code, I can write to him and ask for permission to use it under a different license than the one it&#8217;s published under — specifically, one which doesn&#8217;t contain this citation clause.  Probably he&#8217;ll agree, and that will be that.</p>
<p>However, this is where the first example is relevant.  What if it was something in Carsten&#8217;s code that I wanted to reuse, and he had a similar sort of clause in his license?  Plain and simple, I&#8217;d be stuck.  Even if I were willing to ignore the license on the assumption that his heirs wouldn&#8217;t find out or wouldn&#8217;t care enough to sue me, I certainly couldn&#8217;t relicense the code with a clear conscience.</p>
<p>That&#8217;s why license compatibility is important, and why it&#8217;s a bad idea to add private clauses like the &#8220;cite my paper&#8221; clause.  Without it, free software isn&#8217;t a commons — it&#8217;s a balkanized set of little gardens fenced off from each other and unable to cross-fertilize.  We&#8217;ve had this problem with railroad tracks, with fire hoses, with all sorts of things early in the industrial revolution; as engineers, you&#8217;d think we&#8217;d know better by now.  Four feet eight and a half inches probably isn&#8217;t the optimal solution for any given railroad in isolation, but it&#8217;s certainly better in practice in the real world for nearly all of them, because it&#8217;s what everyone else uses, and in the long run it&#8217;s just not worth the trouble of being different.</p>
<p>&#8220;But,&#8221; you say, &#8220;I still want people to cite my paper when they use my software!&#8221;</p>
<p>Consider this: Most researchers and users of your program are, by and large, honorable and honest people.  They understand the value of citing sources, and they appreciate that you&#8217;ve written this software and made it available for them to use.  For the vast majority of them, all that you need to do to get them to cite your paper about the software is to ask.</p>
<p>License terms aren&#8217;t &#8220;asking&#8221;.  They&#8217;re a demand, one with legal teeth behind it.  They&#8217;re what you put in there for the people who you don&#8217;t trust to do right, and for the corporations that are too big to have morals at all.  They ought to be the final line in the sand for the things that are vitally important: you don&#8217;t claim you wrote this, you don&#8217;t claim I&#8217;ll support it, you don&#8217;t put restrictions on it that I disagree with.  If it&#8217;s not that critical, and if you wouldn&#8217;t sue someone for ignoring it, then setting it in that sort of legal inflexibility does more harm than good.</p>
<p>Thus, I propose the idea of adding a &#8220;Requests&#8221; or &#8220;Moral Obligations&#8221; section to software licenses, for this sort of thing.  When I release a program that&#8217;s large enough to merit a paper citation if someone uses it, somewhere near the license clause in the documentation will be a section that says something like this: &#8220;The requirements in this section are not legally binding; however, they represent things that the author would appreciate:  If you write a paper based on work that uses this software, please include a citation to my paper, and send me a copy of your paper.  If you create a derivative work based on a this software, tell me about it and let me know how I can get a copy, and include this request if it&#8217;s appropriate.&#8221;</p>
<p>In virtually all cases, that will work just as well as adding those as terms to the software license.  (How do I know it will work?  Well, it already works quite well for the papers themselves, though there the request is implicit rather than stated.)  And, importantly, it will work equally well in the cases where something I asked for turns out to be terribly inconvenient for some reason that I didn&#8217;t think of when I wrote it, even if I&#8217;m not around to change the license terms.</p>
]]></content:encoded>
			<wfw:commentRss>http://notes.dpdx.net/2006/04/24/free-software-licenses-and-obligations/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Random Diversions on Shuffling Cards</title>
		<link>http://notes.dpdx.net/2006/04/06/random-diversions-on-shuffling-cards/</link>
		<comments>http://notes.dpdx.net/2006/04/06/random-diversions-on-shuffling-cards/#comments</comments>
		<pubDate>Thu, 06 Apr 2006 21:45:39 +0000</pubDate>
		<dc:creator>Brooks</dc:creator>
				<category><![CDATA[Programming and People]]></category>

		<guid isPermaLink="false">http://notes.dpdx.net/2006/04/06/random-diversions-on-shuffling-cards/</guid>
		<description><![CDATA[I&#8217;ve been thinking a lot about the idea of practicing programming lately, after reading Steve Yegge&#8217;s &#8220;rant&#8221; on the subject.  His claim is that programming is a lot like playing guitar – just doing a lot of it doesn&#8217;t make you any better; you have to specifically do things that will improve them.
Dave Thomas [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been thinking a lot about the idea of practicing programming lately, after reading Steve Yegge&#8217;s <a href="http://www.cabochon.com/~stevey/blog-rants/practicing-programming.html">&#8220;rant&#8221; on the subject</a>.  His claim is that programming is a lot like playing guitar – just doing a lot of it doesn&#8217;t make you any better; you have to specifically do things that will improve them.</p>
<p>Dave Thomas suggests in his <a href="http://blogs.pragprog.com/cgi-bin/pragdave.cgi/Practices/Kata">Code Kata post</a> that one way of practicing programming is by solving small-but-complex algorithmic problems, and he has a list of suggestions.</p>
<p>In the shower this morning, I was thinking about a problem that would fit nicely in that list.  I&#8217;m writing a complicated bit of code that takes the triangles in a triangular mesh and loads them into a data structure.  It would be nice to test it by taking a given mesh and loading the triangles in various random orders, and that immediately leads to the classic card-shuffling problem: given a list of objects, how does one efficiently sort them into a random order?</p>
<p><span id="more-14"></span>With cards, this is relatively easy at first glance: Put the cards in a stack (i.e., a linked list).  Pick a random card from the current stack, and use it to start a new stack.  Pick another random card, and put it on the stack.  Repeat until the original stack is empty.</p>
<p>In practice, this doesn&#8217;t work so well: people aren&#8217;t very good at picking really random cards.  Or anything else random; this is why <a href="http://www.worldrps.com/advanced.html">random play doesn&#8217;t win rock-scissors-paper contests</a>.  But that&#8217;s a digression; we&#8217;ll assume that we have a &#8220;good enough&#8221; random number generator to use, just like a computer would.</p>
<p>Having a random number generator doesn&#8217;t solve the problem, though.  It picks numbers, not cards.  There&#8217;s still the problem of mapping the number to the card.</p>
<p>The trivial solution is to number the cards in the stack from 1 to 52 (thereby making it an indexed array), get a random number from 1 to 52, and pull out the corresponding card.  That works nicely for the first card, but then we&#8217;ve got a stack of cards that are numbered from 1 to 52, but one of them&#8217;s missing.  Now what?</p>
<p>We could renumber the cards after the one we pulled out, reducing each one&#8217;s number by one so that the deck is numbered from 1 to 51, but that&#8217;s still a lot of work – for the whole deck, it&#8217;s O(<em>n</em><sup>2</sup>).</p>
<p>(Now that I&#8217;m writing this out, I see an obvious solution here that I didn&#8217;t see earlier.  I&#8217;ll get to that later.)</p>
<p>Alternately, we could give up on renumbering the cards, and just leave them in a linked list.  Then, when the random number generator gives us a number, we count down that many cards from the top of the deck.  Again, for the whole deck, we end up counting O(<em>n</em><sup>2</sup>) cards.</p>
<p>So, consider an alternate approach: Take the top card off the stack, and put it in a random place in the new stack.  This looks like the same problem – how is locating a random place easier than locating a random card – but there&#8217;s a twist.  Because we&#8217;re doing this in a computer, we can keep the cards in two orders at once.  We can store them in one order that makes them easy to find, and simultaneously in another order that&#8217;s randomized.</p>
<p>First, consider the new deck as a linked list; we pick a card randomly, and insert the new card after it.  On a pointer level, this means that the new card points to what the old card had pointed to, and the old card now points at the new card.  The trick is that, when picking a random card, we don&#8217;t have any reason to care what order they&#8217;re in in the linked list.  So, if we&#8217;re actually storing the cards in an indexed array, and putting each new card on the end of the array, then all we need to do is pick a random index and go straight to that card.  Once all the cards are in the new deck, then we can traverse the linked list and pull them out in the shuffled order.</p>
<p>There&#8217;s a bit of nice optimization, too; we could pull cards off the bottom of the old deck just as easily as off the top, and since we&#8217;re putting them on the top of the new deck (insofar as actual storage location), there&#8217;s no need to actually move the cards at all; everything below the current index is the new deck, and above it is the old deck.  If the cards are just numbers, there&#8217;s no need to even store the cards at all; we just store the pointers.</p>
<p>So, how does that actually get implemented?  Start at the beginning of an indexed array of pointers (which are really just numbers).  Increment the index.  Pick a random bin below the current index.  Take the number from the random bin and put it in the bin corresponding to the current index.  Put the current index as a pointer in the random bin.  Repeat until done.</p>
<p>&#8230;</p>
<p>So, back to that parenthetical note from earlier.  There&#8217;s really no need to renumber all the cards, because they don&#8217;t have to stay in the same order.  We could just take last card on the deck, and renumber it to fit in the gap, and be done.  So, we take a random card out of the deck, put it at the first spot of the new deck, and then move the last card from the deck into the hole that got left.  Or, to do this in the same space, we could just pick a card, set it aside, take the first card from the deck and set it in the hole, and put the picked card in the now-empty first spot.  Now, the &#8220;new deck&#8221; is the first card, and the &#8220;old deck&#8221; is the rest, and so forth as we go along.</p>
<p>How does that get implemented?</p>
<p>Start at the beginning of an indexed array of card numbers (which are essentially pointers).  Increment the index.  Pick a random bin above the current index.  Take the number from the random bin and put it in the bin corresponding to the current index (i.e., the end of the new deck).  Take the current index (i.e., the card from the end of the old deck) and put it in the random bin.</p>
<p>An interesting similarity, isn&#8217;t it?</p>
]]></content:encoded>
			<wfw:commentRss>http://notes.dpdx.net/2006/04/06/random-diversions-on-shuffling-cards/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What does online commerce have to do with free software?</title>
		<link>http://notes.dpdx.net/2006/03/06/what-does-online-commerce-have-to-do-with-free-software/</link>
		<comments>http://notes.dpdx.net/2006/03/06/what-does-online-commerce-have-to-do-with-free-software/#comments</comments>
		<pubDate>Tue, 07 Mar 2006 02:12:40 +0000</pubDate>
		<dc:creator>Brooks</dc:creator>
				<category><![CDATA[Programming and People]]></category>

		<guid isPermaLink="false">http://notes.dpdx.net/2006/03/06/what-does-online-commerce-have-to-do-with-free-software/</guid>
		<description><![CDATA[Rick Segal just referenced a post by Russell Beattie, about &#8220;Web 2.0&#8243; hype and the proliferation of companies with business plans that seem to have plenty of ideas on how to provide value to the people who visit their website or use their services, but seem to have omitted the part where they get paid.
There&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://ricksegal.typepad.com/pmv/">Rick Segal</a> just <a href="http://ricksegal.typepad.com/pmv/2006/03/russell_beattie.html#comments">referenced</a> a <a href="http://www.russellbeattie.com/notebook/1008838.html">post by Russell Beattie</a>, about &#8220;Web 2.0&#8243; hype and the proliferation of companies with business plans that seem to have plenty of ideas on how to provide value to the people who visit their website or use their services, but seem to have omitted the part where they get paid.</p>
<p>There&#8217;s an interesting contrast between Rick and Russ&#8217;s idea of a good business plan and some parts of the free software world, which in many ways ends up being about the free-as-in-free-beer even if that&#8217;s not the actual drive.  I think the difference is much shallower than it appears &#8212; and I think the similarities are quite important, because I suspect that much of the Web 2.0 hype is based on seeing the success of free software but missing the point of why it works.</p>
<p>To start with an immediately handy example, consider the <a href="http://dpdx.net/openfoam-cygwin">Windows port of the OpenFOAM computational fluid dynamics software</a> that I&#8217;m distributing.  On the face of it, my doing this seems to completely ignore Russ&#8217;s point – the packages for that represent a good week of my own work (above and beyond the hard work of the people who wrote the original program and created the initial version of the port), and here I am giving it away without charging a penny.</p>
<p>And, if you look at it like that, you&#8217;ve probably missed the key point.</p>
<p>My business plan, metaphorically speaking, goes like this: I have the knowledge and experience to develop simulation methods for fluid flows and improve the state of the art in that field.  People pay me (in the form of a student research assistanceship, at present, and in the form of research positions after I graduate) to improve the state of the art in ways that benefit them.  This is straightforward, simple, and quite clear about who pays me and why.</p>
<p>One of the pieces that&#8217;s not in that description is the fact that, in order to advance the state of the art, I need good tools.  That&#8217;s where creating and distributing the port of OpenFOAM comes in.  Creating the port is essentially a sunk cost as far as the distribution question is concerned; I did that because I needed it, and because the experience I gained was valuable.  Distributing it, once I&#8217;ve created it, doesn&#8217;t cost much; thus, it doesn&#8217;t take much value to make it worth doing.</p>
<p>So, let&#8217;s get back to the key point: What <i>is</i> the value I expect from this?  I expect to get feedback from people who use it; bug reports and patches.  Those improve the tool, and that means that I have a better tool to use in the core value-generation equation.  Moreover, I have a better tool for less than it would have cost me to find all the bugs and write the patches myself, and that&#8217;s time I can use for working on the problems I&#8217;m being paid to research.  That&#8217;s worth real money, and the conversion process is pretty clear.</p>
<p>This business plan scales up to actual companies, too.  <a href="http://www.opencfd.co.uk">OpenCFD</a>, who wrote and distribute OpenFOAM, have a similar business model.  People pay them to solve fluid-flow simulation problems, or to develop systems to do the simulations.  OpenFOAM is a large part of their toolbox, and the benefits they get from having a large and participatory userbase (and, specifically, a userbase of potential customers) pay for the costs of distributing it.</p>
<p>So what&#8217;s my takeaway message from Russ&#8217;s post, then?  If the value that I get from distributing this software is the feedback that I get from users, then I need to put make it very clear and obvious how they can do that, and effortless for them to do so – because that connection is how I get &#8220;paid&#8221;.  Right now, all I&#8217;ve got is a non-obvious and munged email link at the bottom of the page, and that&#8217;s not good enough.</p>
]]></content:encoded>
			<wfw:commentRss>http://notes.dpdx.net/2006/03/06/what-does-online-commerce-have-to-do-with-free-software/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
