<?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/"
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Neil Dickson's Blog</title>
	<atom:link href="http://ndickson.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://ndickson.wordpress.com</link>
	<description>Inventor IDE, PwnOS, and most everything else I'm up to</description>
	<lastBuildDate>Thu, 09 Jul 2009 08:28:16 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<image>
		<url>http://www.gravatar.com/blavatar/39425d5e6fd805e583ea209d05d9fdf7?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Neil Dickson's Blog</title>
		<link>http://ndickson.wordpress.com</link>
	</image>
			<item>
		<title>Inventor Performance Viewer</title>
		<link>http://ndickson.wordpress.com/2009/07/09/inventor-performance-viewer/</link>
		<comments>http://ndickson.wordpress.com/2009/07/09/inventor-performance-viewer/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 08:22:48 +0000</pubDate>
		<dc:creator>Neil Dickson</dc:creator>
				<category><![CDATA[Optimization]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[PwnIDE]]></category>

		<guid isPermaLink="false">http://ndickson.wordpress.com/?p=164</guid>
		<description><![CDATA[I recently put off the release of Inventor IDE Alpha 5b (probably coming in August, since my honours project is highest priority now) to get something ready for DemoCamp Vancouver that I&#8217;ve been wanting for a very long time.  It&#8217;s a feature that probably won&#8217;t be released until Alpha 6, but you can be certain [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndickson.wordpress.com&blog=1158540&post=164&subd=ndickson&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I recently put off the release of <a href="http://www.codecortex.com/ide/">Inventor IDE</a> Alpha 5b (probably coming in August, since my honours project is highest priority now) to get something ready for <a href="http://www.facebook.com/group.php?gid=2426652061">DemoCamp Vancouver</a> that I&#8217;ve been wanting for a very long time.  It&#8217;s a feature that probably won&#8217;t be released until Alpha 6, but you can be certain that I&#8217;ll try to make good use of it at D-Wave as soon as I can.  I consider it the first truly awesome feature of Inventor IDE.  It&#8217;s easiest to introduce with a picture:</p>
<p style="text-align:left;">
<div id="attachment_163" class="wp-caption aligncenter" style="width: 507px"><a href="http://ndickson.files.wordpress.com/2009/07/sorting.png"><img class="size-full wp-image-163" title="Sorting Performance Analysis" src="http://ndickson.files.wordpress.com/2009/07/sorting.png?w=497&#038;h=357" alt="Rock-solid sorting performance data literally in the blink of an eye" width="497" height="357" /></a><p class="wp-caption-text">Rock-solid performance data literally in the blink of an eye</p></div>
<p style="text-align:left;">(In case you&#8217;re wondering, the times are in clock cycles on a 1.66GHz laptop, so 100,000 clocks = 60 microseconds.)</p>
<p style="text-align:left;">A big problem in doing performance analysis is that getting reliable results and useful scaling info usually means tests that take minutes, so that the impact of the OS or other applications levels off to a constant factor.  If you try to do short tests, you get issues like these:</p>
<p style="text-align:left;">
<div id="attachment_165" class="wp-caption aligncenter" style="width: 310px"><a href="http://ndickson.files.wordpress.com/2009/07/baddata.png"><img class="size-medium wp-image-165" title="BadData" src="http://ndickson.files.wordpress.com/2009/07/baddata.png?w=300&#038;h=208" alt="Bad Performance Data for 2 Mersenne Twister Implementations" width="300" height="208" /></a><p class="wp-caption-text">Bad Performance Data for 2 Mersenne Twister Implementations</p></div>
<div id="attachment_166" class="wp-caption aligncenter" style="width: 310px"><a href="http://ndickson.files.wordpress.com/2009/07/baddata2.png"><img class="size-medium wp-image-166" title="BadData2" src="http://ndickson.files.wordpress.com/2009/07/baddata2.png?w=300&#038;h=214" alt="Bad Performance Data for Sorting Algorithms" width="300" height="214" /></a><p class="wp-caption-text">Bad Performance Data for 3 Sorting Implementations</p></div>
<p style="text-align:left;">These aren&#8217;t exactly reliable results; running a short test multiple times produces wildly different results because of just a few bad data.  On Tuesday around 4am (Pacific Daylight  Time), I finally managed to find a decent approach to eliminate almost all bad data without eliminating much good data.  It&#8217;s certainly not perfect, but here are the results of running the two <a href="http://en.wikipedia.org/wiki/Mersenne_twister">Mersenne Twister</a> tests thrice each while <a href="http://aqua.dwavesys.com/">AQUA@Home</a> is trying to max out the CPU and the harddrive is thrashing like mad (for unknown reasons):</p>
<p style="text-align:left;">
<div id="attachment_167" class="wp-caption aligncenter" style="width: 507px"><a href="http://ndickson.files.wordpress.com/2009/07/mtheavyload.png"><img class="size-full wp-image-167" title="MTHeavyLoad" src="http://ndickson.files.wordpress.com/2009/07/mtheavyload.png?w=497&#038;h=372" alt="Much Better Mersenne Twister Performance Data" width="497" height="372" /></a><p class="wp-caption-text">Much Better Mersenne Twister Performance Data</p></div>
<p style="text-align:left;">It&#8217;s worth pointing out that these times are in fact noticeably worse than the results when the CPU and harddrive aren&#8217;t under heavy load elsewhere (about 1.5 times as long).  The important thing is that the results are still remarkably consistent, and Mersenne128 is still 3.8 times faster than Mersenne32.  You can even still roughly see that Mersenne32 regenerates its data array every 624 elements and Mersenne128 regenerates every 2496 elements.  In case you&#8217;re wondering why CPU times would be so consistently longer instead of scattered, it has to do with process switches flushing the cache and TLBs, only causing cache misses in the good data, whereas the bad data still contain any process switches and other interrupts (like the 1kHz tick and page faults).</p>
<p style="text-align:left;">I&#8217;m still shocked that I can effectively triple-click the test run button on the performance test functions and have the results show up as fast as Windows can show the windows.  It&#8217;s even more responsive than the regular run button in the ImageProgram sample app, and that had shocked me.  That said, I found the ironic-but-not-so-important problem that it names the output files with the time only down to the second, so one that ran in the same second as another wrote over the first&#8217;s data file.</p>
<p style="text-align:left;">This kind of capability finally allows developers to rapidly iterate through possible performance improvements, not only making it faster to optimize, but much easier, because there&#8217;s time to try out many more optimizations in the same amount of time.  For example the faster mergesort in the top graph is from adding a special case for n=2.  In that way, it can also be used as a learning tool for developers to determine what does and doesn&#8217;t improve performance.  Best of all, because of the performance viewer&#8217;s language-independence, its platform-independence, and the many useful analyses it could do on the data, it&#8217;s applicable to many different situations; probably many I won&#8217;t think of myself, so I leave that up to you.  I&#8217;ve just shown you the first glimpse into what I&#8217;ve got planned for it.  <img src='http://s.wordpress.com/wp-includes/images/smilies/face-smile.png' alt=':)' class='wp-smiley' /> </p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ndickson.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ndickson.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ndickson.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ndickson.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ndickson.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ndickson.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ndickson.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ndickson.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ndickson.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ndickson.wordpress.com/164/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndickson.wordpress.com&blog=1158540&post=164&subd=ndickson&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ndickson.wordpress.com/2009/07/09/inventor-performance-viewer/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/accf49d59449b71b817ca3c4f2c739f0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Neil Dickson</media:title>
		</media:content>

		<media:content url="http://ndickson.files.wordpress.com/2009/07/sorting.png" medium="image">
			<media:title type="html">Sorting Performance Analysis</media:title>
		</media:content>

		<media:content url="http://ndickson.files.wordpress.com/2009/07/baddata.png?w=300" medium="image">
			<media:title type="html">BadData</media:title>
		</media:content>

		<media:content url="http://ndickson.files.wordpress.com/2009/07/baddata2.png?w=300" medium="image">
			<media:title type="html">BadData2</media:title>
		</media:content>

		<media:content url="http://ndickson.files.wordpress.com/2009/07/mtheavyload.png" medium="image">
			<media:title type="html">MTHeavyLoad</media:title>
		</media:content>
	</item>
		<item>
		<title>Bugs that never see the light of day</title>
		<link>http://ndickson.wordpress.com/2009/06/21/bugs-that-never-see-the-light-of-day/</link>
		<comments>http://ndickson.wordpress.com/2009/06/21/bugs-that-never-see-the-light-of-day/#comments</comments>
		<pubDate>Sun, 21 Jun 2009 07:30:18 +0000</pubDate>
		<dc:creator>Neil Dickson</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[PwnIDE]]></category>

		<guid isPermaLink="false">http://ndickson.wordpress.com/?p=152</guid>
		<description><![CDATA[Today, I fixed a ton of bugs in Inventor IDE and added some simple-but-useful functionality I&#8217;d been putting off for a long time.  It occurred to me earlier today that for almost all of these bugs, I&#8217;m probably the only one who&#8217;s ever encountered them, and some of them, even I never encountered them; they&#8217;re fixed [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndickson.wordpress.com&blog=1158540&post=152&subd=ndickson&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Today, I fixed a ton of bugs in Inventor IDE and added some simple-but-useful functionality I&#8217;d been putting off for a long time.  It occurred to me earlier today that for almost all of these bugs, I&#8217;m probably the only one who&#8217;s ever encountered them, and some of them, even I never encountered them; they&#8217;re fixed without ever being experienced.  I thought I&#8217;d share some of these bugs with you to give an idea of what I&#8217;ve been up to and what sort of bugs I encounter in Inventor IDE.</p>
<h1>Bug #1: Huge JComboBox</h1>
<p>This is one of those bugs that I can&#8217;t actually fix, but I managed to find a workaround after a whole lot of banging my head against the wall.  There&#8217;s at least one bug in Java&#8217;s implementation of JComboBox that uses the Windows look-and-feel.  It may have been fixed in Java 1.6 or later, but I have to build with Java 1.5 or nothing will run when somebody tries to run it with Java 1.5, even though I&#8217;m not using any Java 1.6 features.</p>
<p>The bug: suddenly and irregularly, the size of a JComboBox will become larger than 16384 x 16384.  When Java tries to create a buffer into which to paint the JComboBox, it runs out of memory, because 16384 x 16384 x 4 bytes per pixel = 1GB.</p>
<p>It took a few hours to figure this out, because the stack trace for the OutOfMemoryError doesn&#8217;t contain any of my code (since I hadn&#8217;t overridden JComboBox.paintComponent()) and the bug rarely occurs.  The way I eventually figured it out was that I put a breakpoint at one of the low levels in the stack trace, ran the code until I got a debugger trace that looked similar, and looked back at the object up the chain at the last pair of paint()/paintChildren() calls, and it turned out to be an ObservedStringComboBox (one of my classes).  It wasn&#8217;t for a few minutes that I realized the size was so huge, and I discovered that getPreferredSize() and getMinimumSize() return similarly huge sizes too, so I traced into them.  After an hour of crawling through the mess that is Java&#8217;s Swing, I found that it was probably that some object was giving a dummy value to indicate that it didn&#8217;t really know how large something was supposed to be.</p>
<p>The solution: I&#8217;ve overridden JComponent.paintComponent() in both classes I have that extend JComboBox, and they check whether the width or height is over 16384, in which case, they do a rough estimation of the size based on the string widths of their options.  Then, they call setSize(), setMinimumSize(), setPreferredSize(), and setMaximumSize(), just to make sure, before calling the original paintComponent().  It successfully picked up the error when it occurred, and set the JComboBox to a reasonable size that didn&#8217;t look out of place.</p>
<h1>Bug #2: Where&#8217;s the caret?</h1>
<p>This bug has been around for quite some time, and although I was stumped on a good way to solve it (partly due to the next bug), it&#8217;s solution was a one-character change.</p>
<p>The bug:</p>
<div id="attachment_153" class="wp-caption aligncenter" style="width: 455px"><a href="http://ndickson.files.wordpress.com/2009/06/caretbad.png"><img class="size-full wp-image-153" title="CaretBad" src="http://ndickson.files.wordpress.com/2009/06/caretbad.png?w=445&#038;h=216" alt="The caret is currently at the beginning of the first &quot;SegmentDescriptor&quot;, but it's impossible to see." width="445" height="216" /></a><p class="wp-caption-text">The caret is currently at the beginning of the first &quot;SegmentDescriptor&quot;, but it&#39;s impossible to see.</p></div>
<p>The border of the LineFields blocks out the one pixel-width of the caret that would be visible if it had no border.</p>
<p>The solution:</p>
<div id="attachment_154" class="wp-caption aligncenter" style="width: 455px"><a href="http://ndickson.files.wordpress.com/2009/06/caretgood.png"><img class="size-full wp-image-154" title="CaretGood" src="http://ndickson.files.wordpress.com/2009/06/caretgood.png?w=445&#038;h=216" alt="The exact same thing, but everything in a LineField is drawn 2 pixels to the right" width="445" height="216" /></a><p class="wp-caption-text">The exact same thing, but everything in a LineField is drawn 2 pixels to the right</p></div>
<p>This was literally solved by changing the insets from (0,0,0,0) to (0,2,0,0).  Now the full caret is visible.  (It didn&#8217;t look as good with just one pixel-width showing, so I have both pixels showing.)</p>
<h1>Bug #3: The layout war</h1>
<p>I hate layout issues; Java seems to have a neverending supply of them, which is why I removed LayoutManagers from a vast majority of the components that need good layout.  There were a few major layout bugs that I still had though, and the most ridiculous-looking was to do with the layout of my ObservedStringTables (shown above correctly, but I&#8217;ll use a new example).</p>
<p>The bug: the ObservedStringTable should control the layout of the LineFields it contains, since they should be kept looking tabular, but many LineFields elsewhere are supposed to resize automatically to fit the current size of their text, so that behaviour was built into LineField.</p>
<div id="attachment_155" class="wp-caption aligncenter" style="width: 480px"><a href="http://ndickson.files.wordpress.com/2009/06/tablebad.png"><img class="size-full wp-image-155" title="TableBad" src="http://ndickson.files.wordpress.com/2009/06/tablebad.png?w=470&#038;h=234" alt="An enumeration isn't supposed to look this bad (btw, here, it auto-increments by &quot;sizeof SegmentDescriptor&quot; if no value specified)" width="470" height="234" /></a><p class="wp-caption-text">An enumeration isn&#39;t supposed to look this bad (btw, here, it auto-increments by &quot;sizeof SegmentDescriptor&quot; if no value specified)</p></div>
<p>The solution: it&#8217;s not a great solution, but by the time it&#8217;s lack of greatness would matter, it&#8217;ll have changed or need changing for other reasons already.  I just have LineField check whether it&#8217;s in an ObservedStringTable, and if it is, it doesn&#8217;t change its own size.</p>
<div id="attachment_156" class="wp-caption aligncenter" style="width: 480px"><a href="http://ndickson.files.wordpress.com/2009/06/tablegood.png"><img class="size-full wp-image-156" title="TableGood" src="http://ndickson.files.wordpress.com/2009/06/tablegood.png?w=470&#038;h=234" alt="TableGood" width="470" height="234" /></a><p class="wp-caption-text">Finally, it looks like a table</p></div>
<p>In case you&#8217;re wondering, yes, the caret is now not visible if it&#8217;s at the end of the Increment field.  I&#8217;ll fix it now, &#8217;cause I&#8217;ll forget something small like that&#8230; there we go; insets are now (0,2,0,2).  <img src='http://s.wordpress.com/wp-includes/images/smilies/face-smile.png' alt=':)' class='wp-smiley' /> </p>
<h1>Bug #4: When the impossible is possible</h1>
<p>Moving away from UI-related bugs, this bug was technically fixed today, though only because today started at midnight, not when I got up (11:30 AM).  A few days ago, I added support for compiling inline functions that have only text-replacement parameters (i.e. macros minus support for elaborate macro stuff).  That way, I can use it for having debug output functions in PwnOS that don&#8217;t get called at all if &#8220;TEXT_TESTING_MODE&#8221; is false.  However, fairly often when compiling, though unpredictably, there&#8217;d be an ArrayIndexOutOfBoundsException when adding a reference to a line or when adding an error to a line.</p>
<p>It&#8217;s fairly common to add errors to lines during compilation, since the error detection doesn&#8217;t check for everything before compile-time, but the only code that would be adding references to lines would be the code for inline function compiling.  When I encounter a call to an inline function, I copy the function, replace the parameter references in the code with their given values, and remove the parameters.  Then I compile it as a regular function, just in the middle of another function.  The weird thing about this error is that upon adding a check to make sure that the array was large enough (which was even redundant, because the line before had been a call to ensureRefCapacity(), which expands the reference array if needed), it still had the same array index exception.  The only way I could think of that this could happen is if multiple threads were messing around with the same line at the same time, but the odds of that were pretty low, considering I&#8217;d explicitly designed the compilation not to modify anything concurrently.</p>
<p>The bug: when a parameter is removed from a function that is in global scope, things observing the global scope get notified about it.  A temporary copy of an inline function shouldn&#8217;t really be notifying the global scope about its parameters being removed, and updating code based on a notification is probably not something that should occur while compiling.  Sure enough, functions didn&#8217;t like getting told that a temporary function they can&#8217;t actually access has lost a parameter.</p>
<p>The solution: this is one bug where I haven&#8217;t actually determined exactly how/why it was occurring, but the stack traces and stepping through debugging clearly showed that the error was only occurring when a temporary function was broadcasting to everybody that it had lost a parameter, which it shouldn&#8217;t be doing.  I just stopped temporary functions from notifying the global scope of anything.  It&#8217;s usually not advisable to fix something without fully understanding it, but often, such a restriction would mean that few bugs would get fixed.  For now, I&#8217;m okay with this lack of understanding, because I&#8217;ll need to re-investigate and adjust this type of thing when I add support for function overloading when I add support for C, and until then, it&#8217;s unlikely that any oversight here will rear its head again.</p>
<h1>Yesterday&#8217;s Bug: The complete round-off problem</h1>
<p>So this wasn&#8217;t from today, but it&#8217;s a cool quirk of floating-point calculation with which programmers should familiarize themselves.  Suppose that you have an array of floats (4-byte real numbers) that&#8217;s 2 billion elements long, and every single element contains the value 1.  If you simply go through the array and sum up the values of the elements, what is the final sum?</p>
<p>You might guess that it&#8217;s 2 billion plus or minus some relatively small amount of error, but in fact, the sum is exactly 8,388,608.  This is the case whether you have 10 million elements, 2 billion elements, or 1 trillion elements.  The answer is still 8,388,608.  Why?</p>
<p>floats have 23 bits of mantissa, and once they get to the value 8,388,608 (i.e. 1.0000&#8230;0×2^23), adding the value 1 would make it 8,388,609, but this can&#8217;t be represented exactly in floating point, so it gets rounded down (following the round even rule), back to 8,388,608.  This happens for every single 1 that is added after that too.  In general, when adding many values that are all positive (or all negative) of similar magnitude, the final sum will be around 8,388,608 times the average value.</p>
<p>This is exactly what I found in a piece of code I had changed to use floats instead of doubles at work (at D-Wave).  It was trying to add 14,400,000 elements with roughly the value 1, and it gave 8,388,608 every time.  Instead of reading the sum, I was actually reading the average, 0.582542 instead of about 1.0, so it wasn&#8217;t immediately apparent why it was wrong.  I realized that this was the error when I ran it for 144,000,000 elements and got 0.058254, which is 10 times less for 10 times as many elements, meaning that the sum hadn&#8217;t changed.  That brings up the question, how do you add up the elements in an array to avoid this?</p>
<p>The solution: Well, the way I fixed it at work was to just change it back to using a double (8-byte real number) to accumulate the values.  That doesn&#8217;t encounter the complete round-off problem until 2^52 additions; it can still result in bad round-off error before then, but it shouldn&#8217;t be an issue for the piece of code we were doing this in.  Is there a way that works for any number of additions?</p>
<p>One way that works in O(logn) extra space (or inline if you can destroy the data), while still being in O(n) time, is that you break it up by adding every pair, then adding every pair of those, then adding every pair of those, etc.  The way that can be done in O(logn) space is that you keep a value for every level, all starting at zero, and when you&#8217;re done a level, you add the value to the next level up.  If that was the end of the next level up, it goes up more, else you go back to the next at the bottom.  This is equivalent to splitting it up recursively (using O(logn) stack space), only without the disadvantages of recursion.  It also has the advantage that it could be done with data coming in over time.  Note that there&#8217;s still the issue of round-off from adding positive and negative numbers that sum to near zero, but there&#8217;s not much that can be done about that.</p>
<p><strong><span style="text-decoration:underline;">Edit:</span> </strong>Here&#8217;s code for this approach (<em>untested</em>):</p>
<pre>float sum(const float*const array,const size_t size) {
    // Assuming there is a function to compute the ceiling of log_2 of size
    // The -1 is because the lowest level (pairs) gets added immediately instead of waiting
    const size_t logSize = ceilLog2(size)-1;
    float accumulators[logSize] = {0};
    bool isSecondHalf[logSize] = {0};
    float sum;
    for (size_t i=0; i&lt;size-1; i+=2) {
        // Add together a pair of elements
        sum = array[i];
        sum += array[i+1];
        size_t level = 0;
        // Go up the tree until reaching the end
        // or a place where it's the first half
        while (isSecondHalf[level]) {
            isSecondHalf[level] = 0;
            accumulators[level] = 0;
            sum += accumulators[level+1]
            ++level;
            // Handle case of size being an exact power of two
            if (level==logSize) {
                return sum;
            }
        }
        // Save the sum at the highest level reached
        accumulators[level] = sum;
        // Now on the second half of that level
        isSecondHalf[level] = 1;
    }
    // Make sure to get the last element if there were an odd number of elements
    sum = (size&amp;1) ? array[size-1] : 0;
    // Add up all values left in accumulators (order matters)
    for (size_t level=0; level&lt;logSize-1; ++level) {
        sum += accumulators[level];
    }
    return sum;
}</pre>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ndickson.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ndickson.wordpress.com/152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ndickson.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ndickson.wordpress.com/152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ndickson.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ndickson.wordpress.com/152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ndickson.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ndickson.wordpress.com/152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ndickson.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ndickson.wordpress.com/152/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndickson.wordpress.com&blog=1158540&post=152&subd=ndickson&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ndickson.wordpress.com/2009/06/21/bugs-that-never-see-the-light-of-day/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/accf49d59449b71b817ca3c4f2c739f0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Neil Dickson</media:title>
		</media:content>

		<media:content url="http://ndickson.files.wordpress.com/2009/06/caretbad.png" medium="image">
			<media:title type="html">CaretBad</media:title>
		</media:content>

		<media:content url="http://ndickson.files.wordpress.com/2009/06/caretgood.png" medium="image">
			<media:title type="html">CaretGood</media:title>
		</media:content>

		<media:content url="http://ndickson.files.wordpress.com/2009/06/tablebad.png" medium="image">
			<media:title type="html">TableBad</media:title>
		</media:content>

		<media:content url="http://ndickson.files.wordpress.com/2009/06/tablegood.png" medium="image">
			<media:title type="html">TableGood</media:title>
		</media:content>
	</item>
		<item>
		<title>PwnOS: First Successful Output</title>
		<link>http://ndickson.wordpress.com/2009/06/07/pwnos-first-successful-output/</link>
		<comments>http://ndickson.wordpress.com/2009/06/07/pwnos-first-successful-output/#comments</comments>
		<pubDate>Sun, 07 Jun 2009 21:40:55 +0000</pubDate>
		<dc:creator>Neil Dickson</dc:creator>
				<category><![CDATA[Carleton]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[PwnOS]]></category>

		<guid isPermaLink="false">http://ndickson.wordpress.com/?p=148</guid>
		<description><![CDATA[This may seem like a small accomplishment to many, but I now have PwnOS boot code that takes one CPU core from 16-bit mode to 32-bit mode to 64-bit mode using code developed and assembled/linked with Inventor IDE.  Until now, so far as I&#8217;ve been able to find, no linker has supported 16-bit, 32-bit, and 64-bit code smoothly [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndickson.wordpress.com&blog=1158540&post=148&subd=ndickson&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>This may seem like a small accomplishment to many, but I now have PwnOS boot code that takes one CPU core from 16-bit mode to 32-bit mode to 64-bit mode using code developed and assembled/linked with <a href="http://www.codecortex.com/ide/">Inventor IDE</a>.  Until now, so far as I&#8217;ve been able to find, no linker has supported 16-bit, 32-bit, and 64-bit code smoothly linked together in one output file.  If that&#8217;s the case, Inventor IDE is the first linker to support this, and it makes developing an operating system bootloader an absolute breeze compared with the alternative, which is to:</p>
<ol>
<li>The 16-bit Master Boot Record (MBR) or Boot Sector (BS) loads the rest of the 16-bit bootloader.</li>
<li>The 16-bit bootloader finds and reads in a file on the drive containing the 32-bit bootloader with an entry point at a hard-coded address.</li>
<li>Switch to 32-bit mode and jump to the hard-coded address.</li>
<li>The 32-bit bootloader finds and reads in a file on the drive containing the 64-bit bootloader with an entry point at a hard-coded address.</li>
<li>Switch to 64-bit mode and jump to the hard-coded address.</li>
<li>The 64-bit bootloader actually starts loading the OS after starting the other CPU cores.</li>
</ol>
<p>Now it&#8217;s as simple as:</p>
<ol>
<li>The 16-bit Master Boot Record (MBR) or Boot Sector (BS) load the entire rest of the bootloader.</li>
<li>Switch to 32-bit mode and jump to the 32-bit starting function (address determined automatically by the linker)</li>
<li>Switch to 64-bit mode and jump to the 64-bit starting function (ditto)</li>
<li>The 64-bit function actually starts loading the OS after starting the other CPU cores.</li>
</ol>
<p>Eliminating the need to find and read in files from a filesystem reduces the size and complexity of the code many-fold.  Plus, now the entire OS should easily fit in the 30KB of disk space I&#8217;ve got for the bootloader, so that first step will load the entire OS from the drive.  I would show a screenshot or photo, but it doesn&#8217;t write to the harddrive yet (it&#8217;s probably for the best), and I don&#8217;t have a working camera anymore.  Nonetheless, here&#8217;s roughly (just in a different font) what was output:</p>
<div id="attachment_149" class="wp-caption aligncenter" style="width: 507px"><a href="http://ndickson.files.wordpress.com/2009/06/firstsuccessfuloutput.png"><img class="size-full wp-image-149" title="FirstSuccessfulOutput" src="http://ndickson.files.wordpress.com/2009/06/firstsuccessfuloutput.png?w=497&#038;h=279" alt="Output showing the PwnOS bootloader switching from 16-bit mode to 32-bit mode to 64-bit mode" width="497" height="279" /></a><p class="wp-caption-text">Output showing the PwnOS bootloader switching from 16-bit mode to 32-bit mode to 64-bit mode</p></div>
<p>There have been similar linkers for just 16-bit and 32-bit code, most notably <a href="http://wiki.osdev.org/JLoc">JLOC</a>.  I would link to the original site, but the site vanished many years ago, which explains why there&#8217;s no support for 64-bit code.  There&#8217;s also the standard linker for linux, <a href="http://wiki.osdev.org/LD">LD</a>.  Although it supports 64-bit code and has extensive scripting options, I can&#8217;t seem to find any evidence that it can link code of different modes together, not to mention that I&#8217;d still need to have a custom assembler to output data to some format it supports that keeps the necessary information.  Also, if LD supported this, linux could get to 64-bit mode in less than 1KB of code, and that certainly isn&#8217;t the case right now.</p>
<p>Hopefully other people will be up for trying this out with Inventor IDE Alpha 5b once it&#8217;s out (just the settings dialog box left).  Anyway, I&#8217;ve written some code for more extensive debugging that I&#8217;m anxious to test out, and I still need to get the other CPU cores up and running, but that should be much easier now.  <img src='http://s.wordpress.com/wp-includes/images/smilies/face-smile-big.png' alt=':D' class='wp-smiley' /> </p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ndickson.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ndickson.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ndickson.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ndickson.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ndickson.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ndickson.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ndickson.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ndickson.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ndickson.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ndickson.wordpress.com/148/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndickson.wordpress.com&blog=1158540&post=148&subd=ndickson&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ndickson.wordpress.com/2009/06/07/pwnos-first-successful-output/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/accf49d59449b71b817ca3c4f2c739f0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Neil Dickson</media:title>
		</media:content>

		<media:content url="http://ndickson.files.wordpress.com/2009/06/firstsuccessfuloutput.png" medium="image">
			<media:title type="html">FirstSuccessfulOutput</media:title>
		</media:content>
	</item>
		<item>
		<title>Inventor IDE Alpha 5a and Inspiration</title>
		<link>http://ndickson.wordpress.com/2009/05/29/inventor-ide-alpha-5a-and-inspiration/</link>
		<comments>http://ndickson.wordpress.com/2009/05/29/inventor-ide-alpha-5a-and-inspiration/#comments</comments>
		<pubDate>Fri, 29 May 2009 20:22:55 +0000</pubDate>
		<dc:creator>Neil Dickson</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[PwnIDE]]></category>

		<guid isPermaLink="false">http://ndickson.wordpress.com/?p=146</guid>
		<description><![CDATA[After fixing dozens of bugs (probably between 50 and 75), adding a Stop button to stop a running app, and adding support for building operating system code, Inventor IDE Alpha 5a is now out.   
It now no longer freezes if an error (like running out of memory) occurs while compiling, and numerous other checks [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndickson.wordpress.com&blog=1158540&post=146&subd=ndickson&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>After fixing dozens of bugs (probably between 50 and 75), adding a Stop button to stop a running app, and adding support for building operating system code, <a href="http://www.codecortex.com/ide/">Inventor IDE Alpha 5a</a> is now out.  <img src='http://s.wordpress.com/wp-includes/images/smilies/face-smile.png' alt=':)' class='wp-smiley' /> </p>
<p>It now no longer freezes if an error (like running out of memory) occurs while compiling, and numerous other checks for errors were added.  If you get an error message, please send me a screenshot and a description of what led to it.  I&#8217;ve got a cool idea for a full debugging system for reproducing errors, but unfortunately, there&#8217;s no way that I have time to make it.</p>
<p>Alpha 5b should be out soon with a project settings dialog box, so that you can choose to make a 64-bit executable, set up the segments in an operating system build, and hopefully create a DLL that actually has exports.</p>
<p>Alpha 6 will introduce what I consider the first <strong><em>truly awesome</em></strong> feature of Inventor IDE, and it&#8217;s something I&#8217;ve been waiting years to see in an IDE, even though it&#8217;s so simple, but you&#8217;ll just have to wait to see what it is&#8230; or badger me until I spill the beans.  <img src='http://s.wordpress.com/wp-includes/images/smilies/face-wink.png' alt=';)' class='wp-smiley' /> </p>
<p>In other news, Code Cortex is now incorporated, so I can start applying for funding, and if that works out, hopefully I&#8217;ll finally be able to start paying people for their work.  Also, I stumbled upon some notes I took at a <a href="http://cutc.ca/">CUTC</a> 2006 presentation by <a href="http://www.infusion.com/">Infusion Development</a>&#8217;s CEO, Greg Brill, and I remembered how inspiring and encouraging they were:</p>
<ul>
<li>make something you&#8217;re passionate about first; don&#8217;t think too hard about the business stuff</li>
<li>find the opportunity missed by the industry now; who&#8217;s being ignored?</li>
<li>business plan sometimes comes after the success</li>
<li>shut up; do something!</li>
<li>try it; fail</li>
<li>business is easy: find a need, fill a need</li>
<li>learn</li>
<li>if you love it, you&#8217;ll do it</li>
</ul>
<p>I get a lot of discouraging, useless business advice, usually from people who only care about making money, so Mr. Brill&#8217;s talk gave me hope that one person really can make a difference.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ndickson.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ndickson.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ndickson.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ndickson.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ndickson.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ndickson.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ndickson.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ndickson.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ndickson.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ndickson.wordpress.com/146/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndickson.wordpress.com&blog=1158540&post=146&subd=ndickson&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ndickson.wordpress.com/2009/05/29/inventor-ide-alpha-5a-and-inspiration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/accf49d59449b71b817ca3c4f2c739f0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Neil Dickson</media:title>
		</media:content>
	</item>
		<item>
		<title>Computer *Science* &#8220;Research&#8221;</title>
		<link>http://ndickson.wordpress.com/2009/05/12/computer-science-research/</link>
		<comments>http://ndickson.wordpress.com/2009/05/12/computer-science-research/#comments</comments>
		<pubDate>Tue, 12 May 2009 10:22:25 +0000</pubDate>
		<dc:creator>Neil Dickson</dc:creator>
				<category><![CDATA[Carleton]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Jobs]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://ndickson.wordpress.com/?p=141</guid>
		<description><![CDATA[I don&#8217;t want people to think that I&#8217;m just some academic hating on companies from an ivory tower in my last post, because at the moment, I blame academia about as much as companies for the lack of innovation for a very different set of reasons.  My apologies for another ranty, depressing post, but I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndickson.wordpress.com&blog=1158540&post=141&subd=ndickson&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I don&#8217;t want people to think that I&#8217;m just some academic hating on companies from an ivory tower in my last post, because at the moment, I blame academia about as much as companies for the lack of innovation for a very different set of reasons.  My apologies for another ranty, depressing post, but I need to let off some steam after the latest encounter with my honours project supervisor.  I&#8217;d like to share an anecdote about one of my roommates when I was at Microsoft.</p>
<p>Joey Jo-jo Junior Shabadoo (fake name at the request of the real guy) is a PhD student (or postdoc, I can&#8217;t recall) in Sweden, specializing in <a href="http://en.wikipedia.org/wiki/Wireless_Sensor_Networks">wireless sensor networks</a> (WSN), and he was in a team at Microsoft Research, developing what sounded like a software toolkit for WSN.  Everybody on his team had a PhD.   There&#8217;s just one problem: PhD computer science researchers in North America aren&#8217;t required to know anything about software, or even computers&#8230; or even science, whereas PhD computer science researchers in Sweden are still required to know how to develop software, since how else could you really determine whether a hypothesis makes sense?  Why is this a problem?</p>
<p>He was the <em><strong>only</strong></em> person on his team who had actually developed much software in recent history.  There was code by his team when he got to Redmond, but all of it was a mess, a much of it was untested, and as it turned out much later, what little of it was tested had faulty tests.  Worse yet, his team hadn&#8217;t decided what hardware they&#8217;d be using yet, and somehow they had code written for some unknown hardware.  When they eventually determined what hardware they&#8217;d use, much of the code no longer made any sense.</p>
<p>Joey was pretty angry about all this, and if you knew him, you&#8217;d know that&#8217;s saying a lot, since he&#8217;s such a light-hearted, fun character.  Moreover, he was determined to get this stuff working.  This guy worked his ass off to pick up the slack for his team.  I&#8217;m talking 10 hours Monday through Friday and 8 hours Saturday and Sunday.  He once worked 12 hours on one Saturday or Sunday to try to fix a bug that turned out to be because a message passing function that was supposedly tested had never been tested with an odd number of bytes, and it failed much of the time when a message had an odd number of bytes.  And no, he was not getting paid for overtime.  By the end of it, he was on the verge of giving up on computer science entirely, and he sounded pretty depressed.  I don&#8217;t blame him; I would&#8217;ve quit or killed myself, since it sounded as bad or worse than <a href="http://ndickson.wordpress.com/2008/08/01/research-in-motion-maintenance-in-stagnation/">my experience at RIM the term before</a>.  I hope he&#8217;s doing well, wherever he is now, and I&#8217;ll send him a link to this to check that I&#8217;ve told the story correctly.</p>
<blockquote><p><a href="http://en.wikipedia.org/wiki/Scientific_method">Scientific method</a> refers to bodies of techniques for investigating phenomena, acquiring new knowledge, or correcting and integrating previous knowledge. To be termed scientific, a method of inquiry must be based on gathering observable, empirical and measurable evidence subject to specific principles of reasoning. A scientific method consists of the collection of data through observation and experimentation, and the formulation and testing of hypotheses.</p></blockquote>
<p>The above is from Wikipedia.  What does it have to do with the story or my distaste for the state of computer science research (in North America)?  We&#8217;ve completely lost the science in computer science.  There is not a single computer science course I&#8217;ve taken or heard of that actually shows anything that would come close to meeting the above definition of scientific.  We don&#8217;t make hypotheses and test them in any courses, we&#8217;re just told to come up with something that does X, often just on paper.  In terms of computer science &#8220;researchers&#8221;, they appear to often just make hypotheses and publish them.  The &#8220;test&#8221; is whether other researchers accept them, but there&#8217;s no real testing of them, no measurements, no experiments, often no principles of reasoning or evidence.  Often when there is testing, it&#8217;s completely irrational, and is either very skewed in favour of those researchers or the tests indicate absolutely nothing.  Why?  Because we&#8217;re all implicitly taught that there&#8217;s no value in testing hypotheses, so they have no idea how to select tests or do systematic testing; they never see it in undergrad, and it evidently doesn&#8217;t get through in grad studies either.</p>
<p>I could give examples of this until I become ill, but I&#8217;ll just give three very different ones:</p>
<ul>
<li><a href="http://portal.acm.org/citation.cfm?id=1105760.1105800&amp;coll=portal&amp;dl=ACM&amp;type=series&amp;idx=SERIES371&amp;part=series&amp;WantType=Proceedings&amp;title=SC&amp;CFID=33541981&amp;CFTOKEN=50518735">Here&#8217;s a paper that claims that OpenMP makes for faster code and is easier to use than MPI for parallelizing.</a> Their testing: get students to use OpenMP on a single computer (which is what it&#8217;s designed for) and get students to use MPI across multiple computers (which is what it&#8217;s designed for) with the same total number of CPU cores; time the students and their code.  If you&#8217;ve done anything with parallel computing, it&#8217;s pretty easy to come up with a correct hypothesis about this experiment.  They neglect to mention that the numbers are completely uncomparable.  One is using several threads on a single computer using shared memory (fast) to communicate implicity (easy), but doesn&#8217;t scale up past one machine (since it isn&#8217;t designed to); the other is using several processes spread across computers using a network (slow) to communicate explicitly (harder), but scales to hundreds of thousands of machines.  Of course OpenMP will be faster and easier to use in their small-scale test case!  If it wasn&#8217;t, it&#8217;d be a complete failure on the part of OpenMP!</li>
<li><a href="http://arxiv.org/PS_cache/cs/pdf/0701/0701023v1.pdf">Here&#8217;s a paper that &#8220;proves&#8221; that P=NP.</a> It took about 5 minutes for me to find a counter-example.  <a href="http://arxiv.org/PS_cache/cs/pdf/0701/0701033v1.pdf">Other people found counterexamples too</a>.  So, the author made <a href="http://arxiv.org/PS_cache/cs/pdf/0701/0701023v4.pdf">a completely new algorithm</a> and claimed that it &#8220;proves&#8221; that P=NP.  I implemented it, picked an arbitrary 10-variable example I found, and it got the wrong answer; <a href="http://arxiv.org/PS_cache/arxiv/pdf/0804/0804.2699v1.pdf">others have too</a>.  He&#8217;s made <a href="http://arxiv.org/PS_cache/cs/pdf/0610/0610042v3.pdf">other algorithms for P=NP</a> that <a href="http://arxiv.org/ftp/cs/papers/0610/0610125.pdf">have been disproven as well</a>.  I was sad to learn that as of recently, <a href="http://rjlipton.wordpress.com/2009/02/13/algorithms-tiny-yet-powerful/#comments">the author <strong><em>still</em></strong> thinks that his algorithms prove that P=NP</a>.  This is a simple matter of that he doesn&#8217;t test his work at all, and leaves it to others to prove him wrong.  It&#8217;s taking &#8220;innocent [of academic fraud] until proven guilty [of academic fraud in every paper]&#8221; to the extreme.</li>
<li><a href="http://arxiv.org/PS_cache/arxiv/pdf/0812/0812.4973v1.pdf">Here&#8217;s one that I wrote myself on jump encoding.</a> <em><strong>Yes, I&#8217;m even willing to bash my own work.</strong></em> It turns out that the statement of assumptions in the abstract is wrong.  It&#8217;s true that it the algorithm isn&#8217;t always space-optimal if an array is declared with a size dependent on the negative of the number of bytes in a section of code, but it&#8217;s also not always space-optimal if people put in preprocessor statements that exclude things based on the size of code.  Of course, it turns out that then it&#8217;s NP-complete just to determine whether there&#8217;s a way to include/exclude code such that no paradoxes occur (e.g. if this code is included, exclude it, and if this code is excluded, include it).  That&#8217;s why assemblers restrict what you can and can&#8217;t do with symbol references, but it is possible to construct some case where the algorithm isn&#8217;t space optimal without running into those restrictions on some assemblers.  I just happen not to care about those cases, since they&#8217;re ridiculous, and not supported by Inventor IDE (they&#8217;re hard enough to support at all, let alone being space-optimal).<br />
What&#8217;s really missing from this paper, other than a formal proof of correctness, is any sort of empirical check of correctness or performance analysis, since I hadn&#8217;t even implemented it yet.  <a title="resolveJumps" href="http://code.google.com/p/pwnide/source/browse/trunk/Base/lang/Encoder.java?r=180#503">The eventual implementation is fairly similar to what&#8217;s described</a>, and it does check out empirically with the testing I&#8217;ve done, but I still haven&#8217;t done any performance testing to see whether it actually runs any faster in practice than the worst-case O(n^2) algorithms that are a bit simpler.  A few people pointed out quite rightly that a very simple O(n^2) algorithm could likely beat the crap out of this O(n) algorithm, which I neglected to state in the paper.  Hopefully I&#8217;ll get a chance to check that once a friend of mine has finished making the next big feature of Inventor IDE, since it&#8217;ll help a ton.  Maybe I&#8217;ll post a new version then.</li>
</ul>
<p>In order to move forward as a field, we absolutely need a course that teaches <em><strong>some</strong></em> form of experiment design and systematic testing, even performance testing.  I don&#8217;t mean garbage like the QA courses I&#8217;ve heard of, I mean real testing for things that are really worth testing.  There was only one assignment I&#8217;ve ever had (assignment #1 of COMP 2402) where we measured the actual time of a piece of code, and it was a toy example with only 5 data points.  I find that outrageous and unacceptable.</p>
<p>In relation to innovation, the academic world is so full of useless papers that finding anything useful in some fields can be a life&#8217;s work.  How can people possibly innovate when they can&#8217;t find out what&#8217;s actually useful and what&#8217;s just empty hypothesis?</p>
<p>I haven&#8217;t even touched on the problem that so much research is doen for the sake of &#8220;wouldn&#8217;t it be cool if ____&#8221; (the answer is no, by the way) or &#8220;this is popular, so it must be important&#8221;.  Researchers are often so separated from the real world that they honestly don&#8217;t even realize that most papers will probably never help anyone.  It reminds me of how a few weeks ago, some lawyers tried to convince me that most users actually read and understand the legal agreements on software.  *sigh*  <img src='http://s.wordpress.com/wp-includes/images/smilies/face-sad.png' alt=':(' class='wp-smiley' /> </p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ndickson.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ndickson.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ndickson.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ndickson.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ndickson.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ndickson.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ndickson.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ndickson.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ndickson.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ndickson.wordpress.com/141/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndickson.wordpress.com&blog=1158540&post=141&subd=ndickson&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ndickson.wordpress.com/2009/05/12/computer-science-research/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/accf49d59449b71b817ca3c4f2c739f0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Neil Dickson</media:title>
		</media:content>
	</item>
		<item>
		<title>Why Companies Don&#8217;t Innovate</title>
		<link>http://ndickson.wordpress.com/2009/05/08/why-companies-dont-innovate/</link>
		<comments>http://ndickson.wordpress.com/2009/05/08/why-companies-dont-innovate/#comments</comments>
		<pubDate>Fri, 08 May 2009 07:43:48 +0000</pubDate>
		<dc:creator>Neil Dickson</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://ndickson.wordpress.com/?p=138</guid>
		<description><![CDATA[The short answer is that &#8220;the market&#8221; is so focused on very-short-term results and completely oblivious to long-term results that executives are pressured into ignoring research &#38; development, instead focusing on sales, marketing, and worst of all, support, of their existing, inadequate technology.
The most absurd version of this extremely dangerous short-term vision that I&#8217;ve seen [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndickson.wordpress.com&blog=1158540&post=138&subd=ndickson&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>The short answer is that &#8220;the market&#8221; is so focused on very-short-term results and completely oblivious to long-term results that executives are pressured into ignoring research &amp; development, instead focusing on sales, marketing, and worst of all, support, of their existing, inadequate technology.</p>
<p>The most absurd version of this extremely dangerous short-term vision that I&#8217;ve seen is <a href="http://en.wikipedia.org/wiki/Kevin_O%27Leary_(entrepreneur)">Kevin O&#8217;Leary</a>, prominent venture capitalist, who&#8217;s frequently said sentences like &#8220;Every day, I want to go to bed richer than when I woke up&#8221; (forgive me if that&#8217;s not a perfect quotation), and on Squeeze Play (a show on BNN) tried to argue that <em><strong>all</strong></em> U.S. bailout money should have gone directly to tax cuts for the biggest corporate executives.  Why?  Because in the short term, he&#8217;d make more money.  Never mind that in the long term, the consumers would be broke, businesses would then be dropping like flies, and he&#8217;d be sunk, blaming it on everyone but himself.  It&#8217;s this kind of short-sighted attitude that makes me want to never give him any control in Code Cortex or any other business I might start.</p>
<p>Anyway, that&#8217;s of course not the entire story.  The key realization that many executives seem to have had (if only subconciously) is that it&#8217;s cheaper to just market what already exists than to make something new and market it.  There are three main reasons that this is technically true: 1) developing something new costs money, whereas not developing anything new doesn&#8217;t; 2) it&#8217;s generally easier to market something that already exists than something new, because the customers already partly understand it, even if the something new is a significant improvement over what&#8217;s already there; and 3) trying something new might not work, whereas doing the same thing that worked before will probably continue to work for long enough to make more money from it.</p>
<p>This is clearly the approach that Visual Studio, or more specifically, Visual C++ is taking, i.e. put out the same product for 12 years, only updating the version number and a few icons.  Quite frankly, they have no excuse, because a 3rd-party company, <a href="http://www.wholetomato.com/">Whole Tomato</a>, has made a <em><strong>plugin</strong></em> called Visual Assist X that fixes many of the design flaws of Visual C++, and includes a few critical features that Visual C++ just neglected to bother including.  It&#8217;s this kind of negligence that has led to a big chunk of Microsoft not using Visual Studio, their own product, for development, instead using 3rd-party programs like <a href="http://www.sourceinsight.com/">Source Insight</a>.  For the record, I find that Source Insight is only marginally better than Visual C++, partly because their default UI is analogous to puking text of all sizes and styles all over the screen&#8230; if you replace &#8220;is analogous to&#8221; with &#8220;looks exactly like&#8221;.  Their UI was actually a big wakeup call for me as far as what NOT to include in <a href="http://www.codecortex.com/ide/">Inventor IDE</a>.  Some people also swear by Eclipse CDT, but I&#8217;ve never been able to get it to find either GCC or the Microsoft C compiler in order to compile.  Anyway, enough ranting about my discontent with existing IDEs and back to the topic at hand.</p>
<p>The case of Visual C++ at least shows that if you choose not to innovate for long enough, your customers will eventually leave you.  However, there&#8217;s another side to pushing marketing &amp; sales instead of innovation, and its perhaps best exemplified by the housing and auto industries as of late.  The focus is so much on that of short-term sales that they&#8217;ve completely saturated the market.  Everyone who wanted a car had a car, and everyone who wanted a house had a house, so sales plummet to much less than the steady-state sales (e.g. sales from new home buyers plus sales from people whose houses are being destroyed).  Why would they try to push sales beyond the maximum steady-state sales?  It&#8217;s fairly obvious that doing this will cause sales to plummet as soon as the market comes anywhere close to saturation, but their concern is that steady-state sales don&#8217;t increase (or at least not much faster than the rate of population increase).  The market has brainwashed them to think that it&#8217;s a failure if sales stay constant, so they push sales as much as possible until they explode.</p>
<p>Notice that there&#8217;s no mention of innovation in this scheme.  Many have said that the reason that the car companies have failed is that they haven&#8217;t researched or developed any environmentally friendly vehicles, and I partly agree, but think that the problem is more fundamental then that.  The vehicles available from major manufacturers are effectively <em><strong>identical</strong></em> to those from 30 years ago.  Maybe a few minor changes have occurred, such as different &#8220;decoration&#8221; on the outside and inclusion of computer systems in some vehicles, but there&#8217;s nothing innovative about them whatsoever.  The manufacturers are so blinded by pushing sales of things we don&#8217;t want down are throats, that they just never realized that we didn&#8217;t want what they&#8217;re making.  To put it bluntly, the last time I wanted a &#8220;tough truck&#8221; was when I was a 4-year-old, because I didn&#8217;t realize that I didn&#8217;t have a practical use for one; somehow I don&#8217;t think that they&#8217;re trying to target the 4-year-old child market.  For Ford&#8217;s sake!  Stop trying to sell us &#8220;tough trucks&#8221;!</p>
<p>This brings me to a related lack of innovation, and its one that really hits home for me.  In the fall, I took the Distributed Operating Systems course at Carleton, and <a href="http://homeostasis.scs.carleton.ca/~soma/distos/fall2008/alto.pdf">one of the first papers we read was on the Xerox Alto</a> computer built between 1973 and 1979.  The most shocking thing about this paper is that if you changed just the numbers in the paper, the computer it describes could, for the most part, describe a modern-day computer.  They had full graphical displays, keyboard &amp; mouse, 3Mbps Ethernet, tablet devices, printers &amp; scanners.  Heck, I can&#8217;t even get a <em><strong>real</strong></em> 3Mbps from my ISP on a modern computer.  In terms of software, they describe anti-aliasing, font rasterization, even using the computers to make an &#8220;internetwork&#8221; system, joining networks of computers using some of the same protocols we use today.  It&#8217;s amazing that they were able to do so much back in the 1970&#8217;s, but it&#8217;s equally amazing that we haven&#8217;t got anything better 30 years later (apart from pumping up the numbers and technology becoming more mobile).  It&#8217;s not for that there haven&#8217;t been good ideas, it&#8217;s that they&#8217;ve all been shot down as not marketable enough in the short term, and for that, we&#8217;re all stuck with what we&#8217;ve got.  All along the way, there&#8217;ve been big companies promising big innovations, and then quietly never delivering.  Remember back in the year 2000, when several big companies were announcing that they had paper-thin, flexible displays already in development?  They keep hoping that you don&#8217;t remember, because its cheaper for them if the consumers want less, and they&#8217;ll do anything to keep it that way.</p>
<p>I&#8217;ll finish by saying that even though I&#8217;m incorporating Code Cortex shortly, I honestly don&#8217;t give a crap about making a company.  I care about changing the world for the better, and if I can&#8217;t do that as a company, I&#8217;ll do it some other way.  So, to all those out there who say that I&#8217;m an idiot because I don&#8217;t have a solid enough business model to get rich quick, I say that you don&#8217;t have a solid enough vision of the future of computation, let alone the future of humanity.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ndickson.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ndickson.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ndickson.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ndickson.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ndickson.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ndickson.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ndickson.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ndickson.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ndickson.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ndickson.wordpress.com/138/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndickson.wordpress.com&blog=1158540&post=138&subd=ndickson&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ndickson.wordpress.com/2009/05/08/why-companies-dont-innovate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/accf49d59449b71b817ca3c4f2c739f0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Neil Dickson</media:title>
		</media:content>
	</item>
		<item>
		<title>Score and MP3 of Sigma X</title>
		<link>http://ndickson.wordpress.com/2009/05/06/score-and-mp3-of-sigma-x/</link>
		<comments>http://ndickson.wordpress.com/2009/05/06/score-and-mp3-of-sigma-x/#comments</comments>
		<pubDate>Wed, 06 May 2009 20:27:31 +0000</pubDate>
		<dc:creator>Neil Dickson</dc:creator>
				<category><![CDATA[Music]]></category>

		<guid isPermaLink="false">http://ndickson.wordpress.com/?p=134</guid>
		<description><![CDATA[As promised, here&#8217;s an MP3 of Sigma X (generated, not a recording), my piece for concert band for assignment 3 of the music composition course I took last term.  Unfortunately, the balance isn&#8217;t very realistic, and I couldn&#8217;t get the suspended cymbal and anvil to sound like they&#8217;re supposed to, so the percussion is absent [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndickson.wordpress.com&blog=1158540&post=134&subd=ndickson&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>As promised, <a title="Sigma X" href="http://www.neildickson.com/music/SigmaX.mp3">here&#8217;s an MP3 of Sigma X</a> (generated, not a recording), my piece for concert band for assignment 3 of the music composition course I took last term.  Unfortunately, the balance isn&#8217;t very realistic, and I couldn&#8217;t get the suspended cymbal and anvil to sound like they&#8217;re supposed to, so the percussion is absent from the MP3.  It&#8217;s really too bad, since the suspended cymbal rolls would add a lot.  <img src='http://s.wordpress.com/wp-includes/images/smilies/face-sad.png' alt=':(' class='wp-smiley' /> </p>
<p><a title="Sigma X Score" href="http://www.neildickson.com/music/SigmaX.pdf">Here&#8217;s the score</a> in case people are interested.  In order to fill out the parts to make it a full concert band piece, I still need to write parts for 3rd Clarinet, 3rd Trumpet, 3rd Trombone, Oboe, Bass Clarinet, Bassoon, 2nd Alto Sax., and Euphonium.  It&#8217;s easy to see how it&#8217;s a lot of work writing for full concert band, but oh well, it&#8217;s fun.  <img src='http://s.wordpress.com/wp-includes/images/smilies/face-smile.png' alt=':)' class='wp-smiley' /> </p>
<p>In case people are wondering about the name, sigma x (<img src='http://s3.wordpress.com/latex.php?latex=%5Csigma_x&#038;bg=161410&#038;fg=999999&#038;s=0' alt='\sigma_x' title='\sigma_x' class='latex' />) is one of the <a href="http://en.wikipedia.org/wiki/Pauli_matrices">Pauli matrices</a>, namely:</p>
<p><img src='http://s1.wordpress.com/latex.php?latex=%5Csigma_x+%3D+%5Cbegin%7Bbmatrix%7D+0%261%5C%5C+1%260+%5Cend%7Bbmatrix%7D&#038;bg=161410&#038;fg=999999&#038;s=0' alt='\sigma_x = \begin{bmatrix} 0&amp;1\\ 1&amp;0 \end{bmatrix}' title='\sigma_x = \begin{bmatrix} 0&amp;1\\ 1&amp;0 \end{bmatrix}' class='latex' /></p>
<p>As an operator, it acts like a NOT gate:</p>
<p><img src='http://s2.wordpress.com/latex.php?latex=%5Csigma_x+%7C0%5Crangle+%3D+%5Cbegin%7Bbmatrix%7D+0%261%5C%5C+1%260+%5Cend%7Bbmatrix%7D+%5Cbegin%7Bbmatrix%7D+1%5C%5C+0+%5Cend%7Bbmatrix%7D+%3D+%5Cbegin%7Bbmatrix%7D+0%5C%5C+1+%5Cend%7Bbmatrix%7D+%3D+%7C1%5Crangle&#038;bg=161410&#038;fg=999999&#038;s=0' alt='\sigma_x |0\rangle = \begin{bmatrix} 0&amp;1\\ 1&amp;0 \end{bmatrix} \begin{bmatrix} 1\\ 0 \end{bmatrix} = \begin{bmatrix} 0\\ 1 \end{bmatrix} = |1\rangle' title='\sigma_x |0\rangle = \begin{bmatrix} 0&amp;1\\ 1&amp;0 \end{bmatrix} \begin{bmatrix} 1\\ 0 \end{bmatrix} = \begin{bmatrix} 0\\ 1 \end{bmatrix} = |1\rangle' class='latex' /></p>
<p><img src='http://s3.wordpress.com/latex.php?latex=%5Csigma_x+%7C1%5Crangle+%3D+%5Cbegin%7Bbmatrix%7D+0%261%5C%5C+1%260+%5Cend%7Bbmatrix%7D+%5Cbegin%7Bbmatrix%7D+0%5C%5C+1+%5Cend%7Bbmatrix%7D+%3D+%5Cbegin%7Bbmatrix%7D+1%5C%5C+0+%5Cend%7Bbmatrix%7D+%3D+%7C0%5Crangle&#038;bg=161410&#038;fg=999999&#038;s=0' alt='\sigma_x |1\rangle = \begin{bmatrix} 0&amp;1\\ 1&amp;0 \end{bmatrix} \begin{bmatrix} 0\\ 1 \end{bmatrix} = \begin{bmatrix} 1\\ 0 \end{bmatrix} = |0\rangle' title='\sigma_x |1\rangle = \begin{bmatrix} 0&amp;1\\ 1&amp;0 \end{bmatrix} \begin{bmatrix} 0\\ 1 \end{bmatrix} = \begin{bmatrix} 1\\ 0 \end{bmatrix} = |0\rangle' class='latex' /></p>
<p>It also represents an observable in quantum mechanics, and as part of a <a href="http://en.wikipedia.org/wiki/Hamiltonian_(quantum_mechanics)">Hamiltonian</a> (energy landscape), it effectively represents the &#8220;amount of <a href="http://en.wikipedia.org/wiki/Quantum_superposition">quantum superposition</a>&#8221; (I know that isn&#8217;t exactly correct, so please don&#8217;t flame me) in a quantum system.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ndickson.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ndickson.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ndickson.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ndickson.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ndickson.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ndickson.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ndickson.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ndickson.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ndickson.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ndickson.wordpress.com/134/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndickson.wordpress.com&blog=1158540&post=134&subd=ndickson&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ndickson.wordpress.com/2009/05/06/score-and-mp3-of-sigma-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://www.neildickson.com/music/SigmaX.mp3" length="4360151" type="audio/mpeg" />
	
		<media:content url="http://0.gravatar.com/avatar/accf49d59449b71b817ca3c4f2c739f0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Neil Dickson</media:title>
		</media:content>
	</item>
		<item>
		<title>Music Composition and Karaoke</title>
		<link>http://ndickson.wordpress.com/2009/05/02/music-composition-and-karaoke/</link>
		<comments>http://ndickson.wordpress.com/2009/05/02/music-composition-and-karaoke/#comments</comments>
		<pubDate>Sat, 02 May 2009 23:20:35 +0000</pubDate>
		<dc:creator>Neil Dickson</dc:creator>
				<category><![CDATA[Music]]></category>

		<guid isPermaLink="false">http://ndickson.wordpress.com/?p=132</guid>
		<description><![CDATA[Many people who know me from computer science at Carleton know that I was in a music composition course this past term.  It was a very interesting format of course, and it really seemed to allow us students to be creative while getting us to experience composing for different ensembles and styles.  We also got [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndickson.wordpress.com&blog=1158540&post=132&subd=ndickson&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Many people who know me from computer science at Carleton know that I was in a music composition course this past term.  It was a very interesting format of course, and it really seemed to allow us students to be creative while getting us to experience composing for different ensembles and styles.  We also got a chance to get ideas and opinions from other students on our work, which was quite useful.  It makes me wonder if a similar format could be applied to a computer science course or two.</p>
<p>The course had 4 assignments: choral composition, string quartet composition, winds composition, anything we want.  Each of the first 3 assignments had a few other restrictions to either give us a bit of guidance or push us out of our comfort zones, but not too much.  For each of these assignments, there was one class where the professor talked about issues of note for the instruments (or voices) for which we were composing, one class where we&#8217;d meet with the prof two at a time to present our ideas and get thoughts from the prof and the other student, and one class where we&#8217;d present our works in progress to the class to get more thoughts from the class.  Then we&#8217;d hand in the assignments in the first class for the next assignment.  Near the end, there was also a class where we got to present finished pieces, and two concerts in which each student had at least one of their compositions performed.</p>
<p>It was great to hear the variety of styles and unique creativity of each of the other students.  One piece in particular, by Fraser Holmes, was called &#8220;Put some lipstick on that pig!&#8221; (not a political reference) and I remember thinking something like &#8220;There aren&#8217;t many pieces that could fit a name like that&#8221;, but man that piece fit the name perfectly.  It was such a neat, funky piece.</p>
<p>For my assignment 3, I wrote a piece for concert band (yes, it was WAY more work than necessary), which I got to briefly rehearse with the Deep River Community Band on Thursday evening.  The professor&#8217;s said that once I fix the issues people brought up, he&#8217;d check around Ottawa for concert bands that might be interested in playing it, since some had asked him for pieces in the past.  My assignment 4 was a string quartet themed on the software development process, and it was performed in our second composition class concert, (although it was botched pretty badly, so they&#8217;re re-recording it.)  I&#8217;ll post the recording of the piece when I get it.  I never really thought that I&#8217;d end up composing something that would be performed.  It&#8217;s a big change from computer science.</p>
<p>On a completely different note, many people also know that I sang regularly on Karaoke Tuesdays at the bar named Mike&#8217;s Place at Carleton, especially 80&#8217;s rock.  I&#8217;ve <strong><em>finally</em></strong> got <a title="Welcome to the Jungle Karaoke" href="http://www.youtube.com/watch?v=HiOsPHWEtug">a video of me singing &#8220;Welcome to the Jungle&#8221;</a> by Guns &#8216;N Roses (not posted by me).  I think it speaks for itself.  I&#8217;ll just say that I have a lot of fun with it, and I&#8217;m not drunk (since I don&#8217;t drink).  <img src='http://s.wordpress.com/wp-includes/images/smilies/face-smile-big.png' alt=':D' class='wp-smiley' /> </p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ndickson.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ndickson.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ndickson.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ndickson.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ndickson.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ndickson.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ndickson.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ndickson.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ndickson.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ndickson.wordpress.com/132/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndickson.wordpress.com&blog=1158540&post=132&subd=ndickson&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ndickson.wordpress.com/2009/05/02/music-composition-and-karaoke/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/accf49d59449b71b817ca3c4f2c739f0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Neil Dickson</media:title>
		</media:content>
	</item>
		<item>
		<title>Inventor IDE Debugging</title>
		<link>http://ndickson.wordpress.com/2009/04/14/inventor-ide-debugging/</link>
		<comments>http://ndickson.wordpress.com/2009/04/14/inventor-ide-debugging/#comments</comments>
		<pubDate>Tue, 14 Apr 2009 07:44:59 +0000</pubDate>
		<dc:creator>Neil Dickson</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[PwnIDE]]></category>

		<guid isPermaLink="false">http://ndickson.wordpress.com/?p=128</guid>
		<description><![CDATA[First, I&#8217;d like to say sorry that I haven&#8217;t yet posted the contest that I&#8217;ve planned to hold.  I&#8217;ve now got a source of legal advice, and since the first contest is for a fairly important-but-simple component of Inventor IDE, I don&#8217;t want to risk screwing it up until I get a lawyer&#8217;s ideas for it.  I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndickson.wordpress.com&blog=1158540&post=128&subd=ndickson&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>First, I&#8217;d like to say sorry that I haven&#8217;t yet posted the contest that I&#8217;ve planned to hold.  I&#8217;ve now got a source of legal advice, and since the first contest is for a fairly important-but-simple component of Inventor IDE, I don&#8217;t want to risk screwing it up until I get a lawyer&#8217;s ideas for it.  I might hold the competition on <a href="http://www.topcoder.com/">Top Coder</a>, but it looks like they&#8217;ve changed their model of letting people host contests.  If I can find someone up for making some really cool interactive GUI components, I could contract it out to them, but I&#8217;d like to see what different people can come up with, since there&#8217;s a lot of room for creativity.</p>
<p>Also, sorry to those who&#8217;ve experienced bugs with <a href="http://www.codecortex.com/ide/">Inventor IDE</a> alpha 5.  I was going to make a special build just for one bug reporter so that I can fix a freezing bug that I can&#8217;t reproduce on my machine.  However there should really be a more extensive debugging system, logging information to files that can help me identify what went wrong when I get a bug report.  As such, I&#8217;ll release the regular version with logging of error information, and a special debugging version that will periodically check for model consistency and log extensively, even when no error has occurred, so that errors can be fixed more easily.  I can&#8217;t give a reliable ETA on this release yet, since I&#8217;ve got a lot going on this week, but it&#8217;s something I really need for future releases anyway.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ndickson.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ndickson.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ndickson.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ndickson.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ndickson.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ndickson.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ndickson.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ndickson.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ndickson.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ndickson.wordpress.com/128/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndickson.wordpress.com&blog=1158540&post=128&subd=ndickson&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ndickson.wordpress.com/2009/04/14/inventor-ide-debugging/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/accf49d59449b71b817ca3c4f2c739f0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Neil Dickson</media:title>
		</media:content>
	</item>
		<item>
		<title>How to Stop Simple Machines Forum Spam</title>
		<link>http://ndickson.wordpress.com/2009/04/04/how-to-stop-simple-machines-forum-spam/</link>
		<comments>http://ndickson.wordpress.com/2009/04/04/how-to-stop-simple-machines-forum-spam/#comments</comments>
		<pubDate>Sun, 05 Apr 2009 00:58:19 +0000</pubDate>
		<dc:creator>Neil Dickson</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[forum]]></category>
		<category><![CDATA[simple machines]]></category>
		<category><![CDATA[SMF]]></category>
		<category><![CDATA[spam]]></category>

		<guid isPermaLink="false">http://ndickson.wordpress.com/?p=121</guid>
		<description><![CDATA[Note: See updates below.  The working solution is in update 3, and it&#8217;s ridiculously simple.  :D
The Code Cortex Forum has had major spam issues since it started, and I knew that it wasn&#8217;t likely that so many spam bots out there were actually figuring out the captchas.  Today I finally figured out how these bots [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndickson.wordpress.com&blog=1158540&post=121&subd=ndickson&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><strong>Note: See updates below.  The working solution is in update 3, and it&#8217;s ridiculously simple.  :D</strong></p>
<p>The <a href="http://www.codecortex.com/forum/">Code Cortex Forum</a> has had major spam issues since it started, and I knew that it wasn&#8217;t likely that so many spam bots out there were actually figuring out the captchas.  Today I finally figured out how these bots were registering so easily.  I won&#8217;t say <em><strong>exactly</strong></em> what I did to stop the spam bots, since if everyone does the same thing, they&#8217;ll just adapt, but I&#8217;ll show why it&#8217;s so easy for them to register, which should be enough to see how to solve the problem.</p>
<p>The following is from &#8220;Sources/Register.php&#8221;:</p>
<pre>if (!defined('SMF'))
	die('Hacking attempt...');</pre>
<p>Yes, you&#8217;re reading that correctly.  That&#8217;s <em><strong>all</strong></em> that&#8217;s done to check whether or not it&#8217;s Simple Machines Forum (SMF) doing the registration, and it&#8217;s the same in all installations of SMF.  This is paired with the following line in &#8220;index.php&#8221; (not &#8220;Sources/index.php&#8221;):</p>
<pre>define('SMF', 1);</pre>
<p>So, in order for a spam bot to register a user, all it does is run that line, set up some HTTP parameters, and then run the Register.php file on your forum.  This can be prevented by adding a small amount of code to your index.php, and a small amount of code to Register.php that checks that the code you added to index.php was run.  This is effectively what SMF was trying to do, but they have the same piece of code for every installation, so the spam bots can just hardcode that and continue undeterred.</p>
<p>I&#8217;d like to see someone come up with an automatic way of generating different code on each package installation/update so that I don&#8217;t have to redo this change whenever I update the forum packages.  Best of luck to you all in stopping the spammers out there!  <img src='http://s.wordpress.com/wp-includes/images/smilies/face-smile.png' alt=':)' class='wp-smiley' /> </p>
<p><strong>Update:</strong></p>
<p>Okay, so maybe I spoke too soon.  Since the change 6 hours ago, I&#8217;ve had two spam users and one spam post, which is about average, so I suppose it didn&#8217;t help much.  <img src='http://s.wordpress.com/wp-includes/images/smilies/face-sad.png' alt=':(' class='wp-smiley' /> </p>
<p><strong>Update 2:</strong></p>
<p>Well, they won&#8217;t entirely prevent spam bots from registering, but I&#8217;ve got a pair of partial solutions that are a bit more crafty and much more successful.  One thing I&#8217;ve got on the Code Cortex Forum is a Spam board that&#8217;s invisible until you&#8217;re logged in, and it&#8217;s the board that appears first.  I&#8217;ve now modified Post.php and Profile.php so that whenever anyone tries to post on this board, instead of posting a message, their account is immediately deleted along with all posts or topics they may have made before.  If you&#8217;d like the code, just comment below or send me an email (you can find my email address on <a href="http://www.neildickson.com/">http://www.neildickson.com/</a>).</p>
<p>I&#8217;ve also made a little script that gets all of the email addresses and user IDs from the forum, checks them against <a title="Stop Forum Spam" href="http://www.stopforumspam.com/">http://www.stopforumspam.com/</a> , and deletes any that appear there.  It tends to time out if more than 30 or so accounts are being deleted, but that&#8217;s not too big of an issue if I just run it once every few weeks now that I have the automatic deletion above.  Running it several times today cut down the number of forum users from over 500 to just 99.</p>
<p>I&#8217;m still curious as to how the spam bots register in the first place, since if SMF did things properly it shouldn&#8217;t be feasible to determine the letters in a captcha from the image, page data, session info, and the fact that the forum is using SMF.  However, I haven&#8217;t got time to look into this now.</p>
<p><strong>Update 3:</strong></p>
<p>So I&#8217;ve figured out how spam bots have been getting in, and I haven&#8217;t had a single new spam bot in 2 days after changing a <span style="text-decoration:underline;">single character</span> in Register.php.  Near the bottom of the Register() function, it generates the code to appear in the captcha and saves it in the session data on the server.  If you have it generate ANYthing different from what it would by default, the spam bots can&#8217;t get in.  You could do this by switching the order of characters in $character_range, adding/removing characters in it, making the captcha a different length, or any combination thereof, plus some other stuff if you really wanted.  Piece of cake, but again, I&#8217;d like a plugin to do this automatically. <img src='http://s.wordpress.com/wp-includes/images/smilies/face-smile-big.png' alt=':D' class='wp-smiley' /> </p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ndickson.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ndickson.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ndickson.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ndickson.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ndickson.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ndickson.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ndickson.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ndickson.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ndickson.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ndickson.wordpress.com/121/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndickson.wordpress.com&blog=1158540&post=121&subd=ndickson&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ndickson.wordpress.com/2009/04/04/how-to-stop-simple-machines-forum-spam/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/accf49d59449b71b817ca3c4f2c739f0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Neil Dickson</media:title>
		</media:content>
	</item>
	</channel>
</rss>