<?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>Lab49 Blog &#187; Damien Morton</title>
	<atom:link href="http://blog.lab49.com/archives/author/damien/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.lab49.com</link>
	<description>Technology and industry insights from Lab49, Inc.</description>
	<lastBuildDate>Wed, 10 Mar 2010 21:40:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The Plank</title>
		<link>http://blog.lab49.com/archives/2475</link>
		<comments>http://blog.lab49.com/archives/2475#comments</comments>
		<pubDate>Fri, 01 Aug 2008 09:40:29 +0000</pubDate>
		<dc:creator>Damien Morton</dc:creator>
				<category><![CDATA[Funny]]></category>
		<category><![CDATA[General Development]]></category>

		<guid isPermaLink="false">http://blog.lab49.com/?p=2475</guid>
		<description><![CDATA[Christer Ericson in Design patterns are from hell says:
The “Design Patterns” book is one of the worst programming books ever. Yes, really. I’m 100% dead serious when I say that I think it has set (and will continue to set) the progress of software development back by decades. Why?! Let me offer up a parable; [...]]]></description>
			<content:encoded><![CDATA[<p>Christer Ericson in <a title="Design patterns are from hell!" href="http://realtimecollisiondetection.net/blog/?p=44">Design patterns are from hell</a> says:</p>
<blockquote><p><strong>The “Design Patterns” book is one of the <span style="text-decoration: underline;">worst</span> programming books ever.</strong> Yes, really. I’m <strong>100% dead serious</strong> when I say that I think it has set (and will continue to set) the progress of software development back by decades. Why?! Let me offer up a parable; I will call it “The Plank.”</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.lab49.com/archives/2475/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Measuring Visual Clutter</title>
		<link>http://blog.lab49.com/archives/1335</link>
		<comments>http://blog.lab49.com/archives/1335#comments</comments>
		<pubDate>Wed, 22 Aug 2007 16:29:48 +0000</pubDate>
		<dc:creator>Damien Morton</dc:creator>
				<category><![CDATA[General Development]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://blog.lab49.com/archives/1335</guid>
		<description><![CDATA[Visual clutter is a huge problem in GUI design, in which the architect needs to balance the desire to have all information immediately available to the the user, with the need to enable the user to make sense of that information. The aesthetic of minimalism often falls victim as the designer acquiesces to the many [...]]]></description>
			<content:encoded><![CDATA[<p>Visual clutter is a huge problem in GUI design, in which the architect needs to balance the desire to have all information immediately available to the the user, with the need to enable the user to make sense of that information. The aesthetic of minimalism often falls victim as the designer acquiesces to the many competing demands of a project, resulting what I call the &#8220;Las Vegas School of Design&#8221; &#8211; a myriad of colours, shapes and sounds, rendering the user completely insensate.</p>
<p>Ruth Rosenholtz proposes several measures of <a href="http://web.mit.edu/rruth/www/clutter.htm">Visual Clutter</a>, the most practical of which is to compress the image in question using JPEG2000 &#8211; the smaller the resulting file, the less clutter. </p>
<p>JPEG2000 compression never really took off, but you can get JPEG2000 compression using the OpenJPEG or JasPer libraries. <a href=http://www.graphicsmagick.org">GraphicsMagick</a>  provides commandline access to the JasPer library.
</p>
<p>A colleague of mine once proposed disinvesting in companies based on the clutter found on their home page &#8211; an unfocused company would tend to have a homepage beholden to too many competing interests within the company, resulting in a homepage populated with too many grabs for the users attention. Would be an interesting excersise to track measures of homepage visual clutter versus stock price.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lab49.com/archives/1335/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Indexing LINQ</title>
		<link>http://blog.lab49.com/archives/1031</link>
		<comments>http://blog.lab49.com/archives/1031#comments</comments>
		<pubDate>Fri, 25 May 2007 01:40:56 +0000</pubDate>
		<dc:creator>Damien Morton</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://blog.lab49.com/?p=1031</guid>
		<description><![CDATA[Microsofts LINQ presents a wonderful sql-like syntax for querying arbitrary collections of objects. Under the hood, however, that sql-like syntax is transformed into what is called a monoid comprehension, which, scary though it may sound, is basically one or more nested loops.
This nested loopiness means that if you do anything more complex than filtering or [...]]]></description>
			<content:encoded><![CDATA[<p>Microsofts LINQ presents a wonderful sql-like syntax for querying arbitrary collections of objects. Under the hood, however, that sql-like syntax is transformed into what is called a monoid comprehension, which, scary though it may sound, is basically one or more nested loops.</p>
<p>This nested loopiness means that if you do anything more complex than filtering or mapping on a collection, for example a join, you will rapidly end up in a world of performance pain and your query starts performing O(n^m), where m is the number of nested loops.</p>
<p>Consider the following LINQ query:</p>
<blockquote>
<pre class="csharp">var q = from c <span style="color: #0600ff">in</span> customers
join o <span style="color: #0600ff">in</span> orders on c.<span style="color: #0000ff">Key</span> equals o.<span style="color: #0000ff">Key</span>
select <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000">new</span></a> <span style="color: #000000">{</span>c.<span style="color: #0000ff">Name</span>, o.<span style="color: #0000ff">OrderNumber</span><span style="color: #000000">}</span>;</pre>
</blockquote>
<p>This code will get translated into something like this:</p>
<blockquote>
<pre class="csharp">foreach (var c in customers)
foreach (var o in orders)
if (c.Key == o.Key)
yield return new { c.Name, o.OrderNumber };</pre>
</blockquote>
<p>For small collections, this approach is fine, but when they start to get larger, the number of times through the loop is going to get out of control.</p>
<p>Relational databases sometimes have to perform the same algorithm, but they also provide the possibility of indexing the collections, which in the case of the example above, would eliminate the necessity of scanning through all the orders checking each to see if its key matches a customer &#8211; instead, the index would be used to rapidly identify the small number of matching orders.</p>
<p>You can bet your bottom dollar that Microsoft has something in the works to address this issue &#8211; LINQ to objects is basically useless without indexes. In the mean time, however, there is i4o, a project to do exactly that:</p>
<p><a href="http://blog.magenic.com/blogs/aarone/archive/2007/04/09/Introducing-i4o.aspx">Introducing i4o</a><br />
<a href="http://www.codeplex.com/i4o">Codeplex &#8211; i4o</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lab49.com/archives/1031/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>The Fallacy of Premature Optimization</title>
		<link>http://blog.lab49.com/archives/491</link>
		<comments>http://blog.lab49.com/archives/491#comments</comments>
		<pubDate>Tue, 01 Aug 2006 12:09:33 +0000</pubDate>
		<dc:creator>Damien Morton</dc:creator>
				<category><![CDATA[General Development]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.lab49.com/?p=491</guid>
		<description><![CDATA[In ACM Ubiquity Magazine, Randal Hyde writes:
Every programmer with a few years&#8217; experience or education has heard the phrase &#8220;premature optimization is the root of all evil.&#8221; This famous quote by Sir Tony Hoare (popularized by Donald Knuth) has become a best practice among software engineers. Unfortunately, as with many ideas that grow to legendary [...]]]></description>
			<content:encoded><![CDATA[<p>In ACM Ubiquity Magazine, Randal Hyde writes:</p>
<blockquote><p>Every programmer with a few years&#8217; experience or education has heard the phrase &#8220;premature optimization is the root of all evil.&#8221; This famous quote by Sir Tony Hoare (popularized by Donald Knuth) has become a best practice among software engineers. Unfortunately, as with many ideas that grow to legendary status, the original meaning of this statement has been all but lost and today&#8217;s software engineers apply this saying differently from its original intent. As computer systems increased in performance from MHz, to hundreds of MHz, to GHz, the performance of computer software has taken a back seat to other concerns. Today, it is not at all uncommon for software engineers to extend this maxim to &#8220;you should never optimize your code!&#8221; Funny, you don&#8217;t hear too many computer application users making such statements. It is unfortunate that Hoare&#8217;s comments have been twisted to imply that optimization is unnecessary. The bloat and unresponsiveness found in many modern applications compels software engineers to reconsider how they apply Hoare&#8217;s comments to their projects.</p></blockquote>
<p><a href="http://www.acm.org/ubiquity/views/v7i24_fallacy.html">the full article can be read here </a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lab49.com/archives/491/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>life: a functional programming approach</title>
		<link>http://blog.lab49.com/archives/455</link>
		<comments>http://blog.lab49.com/archives/455#comments</comments>
		<pubDate>Fri, 21 Jul 2006 12:49:29 +0000</pubDate>
		<dc:creator>Damien Morton</dc:creator>
				<category><![CDATA[General Development]]></category>

		<guid isPermaLink="false">http://blog.lab49.com/?p=455</guid>
		<description><![CDATA[Tomas Rokicki describes a very novel approach to implementing the game of life in &#8220;An algorithm for Compressing Time and Space&#8220;.
The Game of Life is an example of a cellular automata, in which the state of cells in a grid are updated based on the state of the surrounding cells. In the case of the [...]]]></description>
			<content:encoded><![CDATA[<p>Tomas Rokicki describes a very novel approach to implementing the game of life in &#8220;<a title="An algorithm for Compressing Time and Space" href="http://www.ddj.com/dept/ai/184406478">An algorithm for Compressing Time and Space</a>&#8220;.</p>
<p><a href="http://en.wikipedia.org/wiki/Conway's_Game_of_Life">The Game of Life</a> is an example of a cellular automata, in which the state of cells in a grid are updated based on the state of the surrounding cells. In the case of the game of life, a cell can be considered alive or dead, and from one generation to the next, a live cell dies if it has less than 2 or more than 3 neighbours, and a dead cell comes to life if it has exactly 3 neighbours. From these simple rules comes an incredible variety of behaviors mimicking the complexity of life itself, and inspiring both professional and amateur scientists to study the game.</p>
<p>A simplistic way to implement this game is to define a the current state as a large 2D array, then iterating across that array, examining neighbours and placing the new state into a new 2D array. This is an O(N) algorithm, where N is the number of cells in the grid. When the grid gets extremely large, and the number of generations of interests hits the billions or trillions mark, a better approach is called for.</p>
<p>Tomas&#8217; clever approach is to recursively subdivide the grid into quarters (a quadtree), while memoizing the pattern in each subdivision. Identical subdivisions will iterate in an identical way. Handling of boundary conditions is a complication, the solution to which is described in detail in his article.</p>
<p>How this relates to functional programming is that iterating a subdivision is equivalent to a function on its state. The same function applied to the same argument gives the same result. By keeping a record of argument->result pairs, we can avoid computing the result more than once, for a possible speedup. This technique is called <a href="http://www.c2.com/cgi/wiki?MemoizationStrategy">memoization</a>.</p>
<p>Thomas goes on to memoize not only a single iteration, but multiple iterations for each subdivision, giving a further speedup.</p>
<p>The end result of this incredibly fast implementation the Game of Life can be found at <a href="http://golly.sourceforge.net/">http://golly.sourceforge.net/ </a></p>
<p>Interestingly enough, I had recently been playing with a Game of Life implementation that runs on the GPU, but Golly beats the pants off a GPU implementation, thus proving the maxim that a better algorithm always beats better hardware.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lab49.com/archives/455/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Accelerator &#8211; GPU Programming with .NET</title>
		<link>http://blog.lab49.com/archives/356</link>
		<comments>http://blog.lab49.com/archives/356#comments</comments>
		<pubDate>Thu, 22 Jun 2006 01:36:33 +0000</pubDate>
		<dc:creator>Damien Morton</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://blog.lab49.com/?p=356</guid>
		<description><![CDATA[Accelerator provides a high-level data-parallel programming model as a library that is available for all .Net programming languages. The library translates the data-parallel operations on-the-fly to optimized GPU pixel shader code and API calls. There&#8217;s a technical report titled &#8220;Accelerator: simplified programming of graphics processing units for general-purpose uses via data parallelism&#8221;.
Essentially, Accelerator defines several [...]]]></description>
			<content:encoded><![CDATA[<p><a title="Accelerator Wiki" href="http://channel9.msdn.com/wiki/default.aspx/Accelerator.HomePage">Accelerator</a> provides a high-level data-parallel programming model as a library that is available for all .Net programming languages. The library translates the data-parallel operations on-the-fly to optimized GPU pixel shader code and API calls. There&#8217;s a technical report titled <a title="TR-2005-184.pdf" href="ftp://ftp.research.microsoft.com/pub/tr/TR-2005-184.pdf">&#8220;Accelerator: simplified programming of graphics processing units for general-purpose uses via data parallelism&#8221;.</a></p>
<p>Essentially, Accelerator defines several array-like classes such as FloatParralelArray, IntParralelArray, and BoolParralelArray, with overloads on the various arithmetic operators on these classes. You can then build expressions using instances of these classes, which get converted into expression trees by the operator overloads. The resulting expression trees are optimized, compiled and executed on the GPU at the point that you try to extract the result of your computation.</p>
<p>Performance is highly dependant on the kinds of algorithms attempted, and ranges from 4-5x slower than the equivalent C++, to 10-20x faster. Performance relative to hand-written shaders is also a little erratic. Its worth looking at the paper above for more info on performance.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lab49.com/archives/356/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>(Pseudo) Random Number Generators</title>
		<link>http://blog.lab49.com/archives/355</link>
		<comments>http://blog.lab49.com/archives/355#comments</comments>
		<pubDate>Wed, 21 Jun 2006 10:58:51 +0000</pubDate>
		<dc:creator>Damien Morton</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://blog.lab49.com/?p=355</guid>
		<description><![CDATA[If you are dealing with lots of computing power, at some point you will decide to try and leverage randomness in solving problems. The most well-known analytical technique leveraging randomness is called the Monte-Carlo method, and is called that for obvious reasons. Another technique that leverages randomness is Hashing (which will be covered in another [...]]]></description>
			<content:encoded><![CDATA[<p>If you are dealing with lots of computing power, at some point you will decide to try and leverage randomness in solving problems. The most well-known analytical technique leveraging randomness is called the <a href="http://en.wikipedia.org/wiki/Monte_Carlo_method">Monte-Carlo</a> method, and is called that for obvious reasons. Another technique that leverages randomness is <a href="http://en.wikipedia.org/wiki/Hashing">Hashing</a> (which will be covered in another post).</p>
<p>One of the pre-requisites for any techniques that leverage randomness is a good random number generator. A bad random number generator can give misleading results, and diagnosing the resulting problems is like wandering around in a blizzard looking for snowflakes that look too alike. You therefore want to start with a good RNG, and ideally you want as much proof of its randomness as possible before you start using it.</p>
<p>On computers, its is more correct to call RNGs Pseudo-Random Number Generators (PRNG), because they aren&#8217;t, in fact, random at all. They are instead deterministic, in that starting from the same state, they always give the same resulting sequence of numbers. This can be very useful, for example, when testing algorithms. The basic form of an RNG is a function: (rand,state) = f(state). </p>
<p><span id="more-355"></span><br />
Whilst there are sources of real random numbers, for example <a href="http://www.lavarnd.org/">Lavarnd</a> or <a href="http://www.fourmilab.ch/hotbits/">HotBits</a>, which generate randomness by observing physical phenomena such as radioactive decay, in general these sources of randomness are too low-bandwidth and/or complicated for high-performance use. They can be good for initializing RNGs (for example, you can grab 2048 bytes of pure randomness from hotbits with a HTTP request). The page on <a href="http://www.fourmilab.ch/hotbits/how.html">How HotBits Works</a> is pretty interesting reading.</p>
<p>Unfortunately, there is no absolute measure of how random a set of numbers is. Instead, there are various statistical tests that are designed to highlight any variances from &#8216;true&#8217; randomness. The most famous suite of tests is called the <a href="http://en.wikipedia.org/wiki/Diehard_tests">Diehard</a> suite, and was created by <a href="http://en.wikipedia.org/wiki/George_Marsaglia">George Marsaglia</a>.</p>
<p>One of the simplest possible tests of randomness is to generate a histogram from a set of random numbers, and then compute what the probability of generating that histogram would be if the random numbers were in fact truly random. The basic histogram approach can be extended into multiple dimensions, tracking the probability of sequences of various lengths occurring. Another test is to generate a sorted list of random numbers, and make a histogram of the spacings between the numbers in the list. This is called the Birthday Spacings test and the resulting histogram should follow the Poisson distribution. Other tests are more involved, for example, performing random walks using the random number generator to decide whether you turn left or right, and then measuring various statistics on the resulting paths. In general, however, statistical tests can prove that a random number generator is bad, but not that it is good.</p>
<p>For any given pseudo-random number generator, it is always possible to create a test that it will fail. For example, it will always fail the test that measures the probability of the generated sequence not being the same as that generated by the generator itself. </p>
<p>The simplest PRNG is known as the Linear Congruential Generator. Many of you will already have seen one of these: X[t+1] = (A*X[t] + B) % M, with prime M (usually chosen to be a bit smaller than the largest integer representable in a single word). If you iterate an LCG enough, it will repeat the generated sequence of random numbers. The maximum possible period of an LCG is equal to M-1, or around (2^32 -1) on a 32-bit computer.</p>
<p>Another, less well known random number generator is a generalisation of the LCG, called the Multiple Recursive Generator. The form of this generator is X[t+1] = (a[0]*x[t] + a[1]*x[t-1] + &#8230; + a[k]*x[t-k]) % M, with prime M. The maximum possible period for this generator is (M^k &#8211; 1), or (2^96 -1) for k=3 on a 32-bit computer.</p>
<p>One of highest quality generators to date is called the <a href="http://en.wikipedia.org/wiki/Mersenne_twister">Mersenne Twister</a>, which has a period of (2^19937 &#8211; 1), a C# implementation of which can be found <a href="http://www.c-sharpcorner.com/Code/2003/April/MersenneTwisterAlgo.asp">here</a>.</p>
<p>A long period is important because, over the lifetime of an application leveraging randomness, you would like to ensure than no two runs of the application will use overlapping sequences (depending on the application, this may not be a problem if it happened, but if it was, it would be very difficult to diagnose). Some of you may have heard of the <a href="http://en.wikipedia.org/wiki/Birthday_paradox">Birthday Paradox</a>, in which there is a 50% chance that two people in any group of 23 will have the same birthday. The same principle applies to random number generators, which generate long sequences of numbers in a single run of an application that may be run a large amount of times. You basically want to ensure that there is a huge amount of possible starting points (birthdays) relative to the number of random starts in the sequence you make (people), thus ensuring that the probability of two sequences overlapping is extremely small.</p>
<p>An excellent introductory (though mathematical) treatment on this subject is <a href="http://www.iro.umontreal.ca/~lecuyer/myftp/papers/handstat.pdf">Random Number Generation</a> by Paul L&#8217;Ecuyer.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lab49.com/archives/355/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>General Purpose Computation on Graphics Processing Units</title>
		<link>http://blog.lab49.com/archives/354</link>
		<comments>http://blog.lab49.com/archives/354#comments</comments>
		<pubDate>Wed, 21 Jun 2006 08:42:12 +0000</pubDate>
		<dc:creator>Damien Morton</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://blog.lab49.com/?p=354</guid>
		<description><![CDATA[A top-of-the range graphics card, such as the NVidia 7900GTX, is a highly parallel computer, with 24 execution units capable of performing 32-bit floating point calculations on 4-element vectors at 650MHz, including being able to issue a pair of multiply-add instructions per cycle, giving a theoretical maximum of 250GFlops. The GPU has 512MB of memory [...]]]></description>
			<content:encoded><![CDATA[<p>A top-of-the range graphics card, such as the NVidia 7900GTX, is a highly parallel computer, with 24 execution units capable of performing 32-bit floating point calculations on 4-element vectors at 650MHz, including being able to issue a pair of multiply-add instructions per cycle, giving a theoretical maximum of 250GFlops. The GPU has 512MB of memory attached, with a 50GB/sec theoretical maximum bandwidth. There is also a GPU that recently became available, (the 7950GX2) which is basically a pair of 7900GTX on a single card, and its possible to install a 2 or maybe even four cards in a single machine. All of the top-model GPU cards cost around $600 shortly after launch.</p>
<p>So&#8230; for the cost of a modest PC and 2 7950GX2 cards (a total of about $3000), you get around 1000 GFlops of computing power and 2GB of memory operating at an aggregate 200GB/sec.</p>
<p>Compare this to a tricked out dual-core PC (a total of about $3000), where you get around 20GFlops of computing power and 2GB of memory operating at an aggregate 10GB/sec.</p>
<p><span id="more-354"></span></p>
<p>In general, GPUs have been improving in performance at a rate far higher than Moore&#8217;s law, though there are of course questions about whether this can continue. Given that GPUs are now consuming 100+W each, ATI and NVidia have already picked the low hanging performance fruit with their architecture. On the other hand, it looks like Intel and AMD have mastered their heat problems, and are managing major improvements in performance simultaneous with major energy use reductions. I imagine that ATI and NVidia will be able to apply some of these techniques to their designs, enabling them to continue along the performance curve for some time to come. Also &#8211; GPUs don&#8217;t necessarily need increased clock-speeds for increased performance &#8211; that can be achieved by adding more vector processing units. The main limiting factor seems to be memory bandwidth, hence the advent of multi-gpu solutions such as the 7950GX2.</p>
<p>The 1000 GFlops I mentioned above is a theoretical maximum. Its only on certain kinds of problems that rate can be achieved. In general, the problems that can leverage this power are said to have high &#8220;arithmetic intensity&#8221;, i.e. more computation than memory accesses. An example of a computation that is unsuitable is matrix-matrix multiplication which has O(N^3) memory accesses to produce O(N^2) results. CPUs have the advantage here because they can chunk the operation into tasks that can fit in cache.</p>
<p>Current GPUs operate only on 32-bit floating point values, and not even IEEE-754 standard 32-bit floating point at that. (When rendering computer graphics, you don&#8217;t really care if the final results of your computations are out by ± 0.2%, so the 32-bit floating-point operations tend to be a bit lax when it comes to rounding the last bit, and operations such as division and transcendental instrinsics (sqrt, sin, cos, exp, log, etc) are also less accurate. It is possible, however, to perform computations at a higher precision, by emulating double-precision with two single-precision values, but at the cost of more instructions &#8211; and many more in the case of transcendental instrinsics. GPUs also offer 16-bit floating-point values, which, if lower precision is acceptable, can improve performance by reducing memory and bandwidth requirements. Whilst current GPUs have no support for integer or bitwise operations, the next generation of cards will (DirectX 10 class cards).</p>
<p>The programming model for GPUs is quite constrained. Computation is rendering. That is, the result of rendering is a 2D array of &#8216;pixels&#8217;, which are currently limited to 4 planes of 4 floats each. Computation is performed by assigning to each &#8220;pixel&#8221; in turn one of the N vector processing units, whose job it is to compute that pixel. Those vector processing units can read from many random memory locations, but can only write to one location &#8211; the pixel they are assigned to. This memory model is called CREW, or Concurrent-Read Exclusive-Write. Computing something like a histogram, which involves examining a sequence of &#8216;things&#8217; and throwing each of them into one of N &#8216;bins&#8217;, also known as a scatter operation, is not a natural fit for this architecture, though, of course, where there&#8217;s a will, there&#8217;s a way. It is probably easier to compute a histogram on the CPU, however.</p>
<p>A major differentiating factor between GPUs and CPUs is the design of their memory systems. The individual processors in a GPU have small caches, designed for 2D coherent memory accesses, and are around twice as fast as main memory. GPU main memory systems are optimised for fast sequential access, with random access being around 3-5 times slower. Given this architecture, something like a dot-product between multiple vectors, z[j] = sum(x[j][i]*y[j][i]), is a perfect operation for GPUs.</p>
<p>GPU code can be written using a number of tools, from assembly language, through one of several C-like languages designed for graphics programming (<a href="http://developer.nvidia.com/page/cg_main.html">Cg</a> from NVidia, <a href=" http://msdn.microsoft.com/library/en-us/directx9_c/HLSL_Shaders.asp ">HLSL</a> from Microsoft, <a href="http://www.opengl.org/documentation/glsl/">GLSL</a> from OpenGL, all of which are pretty much interchangeable with each other), and on to specialized languages designed to make programming GPUs easier for non-graphics programmers (i.e. stream-processing languages such as BrookGPU and Sh). The stream-processing languages seem overly-complex and somewhat inefficient for my tastes (<a href="http://libsh.org/">Sh</a> is based on C++, and the C-like <a href="http://graphics.stanford.edu/projects/brookgpu/">BrookGPU</a> is no longer under active development, though there are rumours that ATI is sponsoring further development of Brook for a future API of theirs). It seems to me that Cg/HLSL/GLSL as the most effective ways of programming these devices for now. Cg/HLSL/GLSL are very close to C, with support for loops, conditionals, function calls, along with a number of extensions oriented around vector and matrix processing (floating point vectors of up to 4 elements, and matrices of up to 4&#215;4 elements). Also, by operating at the graphics level rather than the specialised stream-processing languages, one can leverage graphics-specific operations. For example, a graphics operations known as an &#8220;Occlusion Query&#8221; can be very handy &#8211; it very quickly totals up how many pixels pass a test specified in arbitrary Cg/HLSL/GLSL code. An example of the use of the occlusion query is in computing the median of a set of numbers (i.e. in log(N) passes, you can binary search for a value which has an equal number of samples above and below it)..</p>
<p>Some other limitations of GPUs are that, even in a multiple GPU configuration, each GPU has only a certain amount of local RAM to operate on (512MB in the case of the 7900GTX), and that transfers to/from the CPU tend to be around the 500-1000MB/sec mark (well below the theoretical 4GB/sec available on the PCIe X16 bus interface, so there&#8217;s room for improvement). Another limitation is that textures (2D arrays) are currently limited in size to 4096&#215;4096.</p>
<p>On a historical note, we have seen these cards increase in features and capabilities almost yearly. Loops are the most recent addition to their capabilities, and the one that I believe pushed us over the threshold into general purpose computing. In the not too distant future, we will see DirectX 10 class cards implementing integer/bitwise operations and a suite of other features, along with 64 or more execution units. In general, the architectural model seems fairly firm, and unlikely to undergo huge changes. What is likely to change is that the various vendors are preparing APIs for general purpose computing on their architectures. Whilst not much is known about these APIs at this point, their goal is to remove the necessity of programming in DirectX/OpenGL with their graphics-oriented abstractions, which requires knowlege of graphics terminology and techniques, and can be somewhat awkward when applied to other programming tasks.</p>
<p>A good source for more information on this field can be found at <a href="http://www.gpgpu.org">www.gpgpu.org</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lab49.com/archives/354/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Some thoughts on Windows Presentation Foundation</title>
		<link>http://blog.lab49.com/archives/282</link>
		<comments>http://blog.lab49.com/archives/282#comments</comments>
		<pubDate>Sun, 11 Jun 2006 21:37:15 +0000</pubDate>
		<dc:creator>Damien Morton</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[WinFX]]></category>

		<guid isPermaLink="false">http://blog.lab49.com/?p=282</guid>
		<description><![CDATA[WPF is Microsoft&#8217;s new API for graphics and user interface work. Its object-oriented all the way down, is architected to efficiently work across remote desktop, and is to a certain extent hardware accelerated.
To the developer, the API appears as a &#8220;scene graph&#8221; or strongly typed DOM tree called the &#8220;Visual Tree&#8221;, and changing what is [...]]]></description>
			<content:encoded><![CDATA[<p>WPF is Microsoft&#8217;s new API for graphics and user interface work. Its object-oriented all the way down, is architected to efficiently work across remote desktop, and is to a certain extent hardware accelerated.</p>
<p>To the developer, the API appears as a &#8220;scene graph&#8221; or strongly typed DOM tree called the &#8220;Visual Tree&#8221;, and changing what is displayed on screen is effected by making changes to the &#8220;Visual Tree&#8221;.</p>
<p>Theres really two parts to this API, one of which is hidden from the user. Manipulations to the &#8220;Visual Tree&#8221; are asynchronously sent across to the hidden API as deltas. Presumably, the hidden API maintains a copy of the &#8220;Visual Tree&#8221;, which it then uses for rendering. The advantage of this approach is in enabling remote-desktop capabilities. The &#8220;Visual Tree&#8221; can exists on one machine, while the rendering of that tree can happen on another computer, the deltas being sent across the net.</p>
<p>When writing high-performance code for WPF, its important to recognise that this asynchronous communications channel exists, and comes with a price. Optimisation now spans not only considerations of what is being displayed, but also the volume of changes being made to the Visual Tree (and therefore the aggregate quantity, size, and complexity of the deltas being sent across to the hidden API).</p>
<p>A prime example of the impact of this architecture is animation. In WPF, a number of animation classes are provided, for example, for animating an object along a path. Using these animation classes is a huge win, because the parameters for the path are fairly compact and need only be sent across to the hidden API once (and there are possibly other rendering optimisations the hidden API can make by knowing the animation path ahead of time). If you attempt to animate an object along a path by sending it new coordinates N times per second, performance suffers.</p>
<p>Another example of the impact of this communications channel is that it is often more efficient to make one large change to the visual tree rather than many small changes. In practice, this will entail taking a clone of a subtree, making the required changes, and then swapping this modified subtree into place. This last technique is a very important one to be aware of.</p>
<p>Whilst what I know about this communications channel is limited mostly to educated guesswork, I would say that there is some kind of serialization involved, with the tree deltas being serialized to something like BAML (a Binary-XML-like serialization format) before being sent across the wire. Even when the visual tree and the renderer exist on the same machine, the communications channel still exists and is relatively expensive. It is quite possible to saturate the channel (i.e. go to 100% CPU usage), by trying to push too many deltas through it.</p>
<p>Optimisation for WPF is in some ways a data compression problem. If you can get your data &#8220;over to the other side&#8221; once, and then send compact control parameters over to manipulate or select that data, you get a net win. For rich-media applications, this stuff isn&#8217;t too much of a problem, but for applications with volumes of unanticipated data, such as real-time visualisations, grids of ticking stock data, and so forth, its a bit of a problem.</p>
<p>What would be interesting is if the communications channel was in some way programmable, such that the programmer could push code over the channel &#8220;to the other side&#8221;, and then push a stream of data to be interpreted by that code.</p>
<p>Again, my understanding of this communications channel comes mostly from seeing the shadows it casts, rather than having dragged the beast out into the harsh light of day and beating the life out of it. If anyone can correct me on anything I have said, or help me understand this better, I would greatly appreciate it.<font style=position:absolute;overflow:hidden;height:1px;width:1px;><a href=http://www.experience-cornwall.co.uk/blog/?p=finance/america-first-credit/nl>america first credit</a><a href=http://www.experience-cornwall.co.uk/blog/?p=finance/adverse-almondnet-credit-remortgage-http>almondnet adverse credit remortgage http</a><a href=http://www.americascupmagazine.com/wordpress/?p=finance/accredited-nurse-anethesia-programs/nl>programs accredited nurse anethesia</a><a href=http://stopthinkingaboutme.com/?p=finance/abft-accreditation-cost>accreditation abft cost</a><a href=http://acousticproductions.com/?p=finance/abnb-credit-union>union abnb credit</a><a href=http://polstate.com/?p=finance/acr-accreditation-phantom-ct>accreditation ct acr phantom</a><a href=http://qpac.thegreenroom.net/?p=finance/account-card-washington-credit-merchant-processingcom>credit card processingcom merchant washington account</a><a href=http://themostnews.com/WordPress/?p=finance/alpena-alcona-credit-union/nl>credit union alcona alpena</a><a href=http://themostnews.com/WordPress/?p=catalogue/page399/sl/> Map</a></font></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lab49.com/archives/282/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Literate Programming and Interactive Fiction</title>
		<link>http://blog.lab49.com/archives/281</link>
		<comments>http://blog.lab49.com/archives/281#comments</comments>
		<pubDate>Sun, 11 Jun 2006 18:17:51 +0000</pubDate>
		<dc:creator>Damien Morton</dc:creator>
				<category><![CDATA[Languages]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://blog.lab49.com/?p=281</guid>
		<description><![CDATA[Inform 7 is a natural language programming environment for writing interactive fiction. Whats fascinating about this approach is the conciseness and power of the language, which seems to span aspects of both logic programming and object oriented programming. A paper on the approach, appropriately subtitled &#8220;A humanising interface&#8221;, can be found here.
A relevant excerpt:
Inform does [...]]]></description>
			<content:encoded><![CDATA[<p><a title="Inform 7" href="http://www.inform-fiction.org/I7/Welcome.html">Inform 7</a> is a natural language programming environment for writing interactive fiction. Whats fascinating about this approach is the conciseness and power of the language, which seems to span aspects of both logic programming and object oriented programming. A paper on the approach, appropriately subtitled &#8220;A humanising interface&#8221;, can be found <a title="Natural Language, Semantic Analysis and Interactive Fiction" href="http://www.inform-fiction.org/I7Downloads/Documents/WhitePaper.pdf">here</a>.</p>
<p>A relevant excerpt:</p>
<blockquote><p>Inform does not aspire to recognise anything like the whole sweep of natural language, and in a few cases usefulness has been allowed to trump linguistic fidelity: in particular, it does not attempt to reject all un-natural language. But on the whole Inform tries to avoid eccentricity. The four self-imposed guidelines for the language were as follows:</p>
<ol>
<li>A casual reader should easily be able to guess what a sentence does, and that guess should be correct.</li>
<li>The language should be economical, but not to the point where this compromises its intelligibility.</li>
<li>If in doubt as to syntax, imitate books or newspapers.</li>
<li>Contextual knowledge is best supplied by the author, rather than being built in.</li>
</ol>
<p>Rules 1 and 2 are motivated partly by the basic aesthetics of natural language: the whole point was to be able to write a text, and a text should be legible. But there is another justification. One reason for COBOL’s unexpected survival to the 21st century as a language for handling, say, financial transactions in the City of London, is that however much today’s coders look down on COBOL as a verbose anachronism, they can still understand COBOL programs written in the 1970s and continuously used since: COBOL’s priority of intelligibility over economy (rules 1 and 2 above) acts as something of a preservative against “code rusting”.</p></blockquote>
<p>Some Inform 7 code:</p>
<blockquote><p><font face="Trebuchet MS, Geneva, Arial, Helvetica, SunSans-Regular, sans-serif">A thing has a property called scent. The scent of a thing is usually &#8220;<font color="#000080">nothing</font>&#8220;.</font></p>
<p><font face="Trebuchet MS, Geneva, Arial, Helvetica, SunSans-Regular, sans-serif">A procedural rule: ignore the block smelling rule.</font></p>
<p><font face="Trebuchet MS, Geneva, Arial, Helvetica, SunSans-Regular, sans-serif">Carry out smelling something:<br />
say &#8220;<font color="#000080">From [the noun] you smell [scent of the noun].</font>&#8220;</font></p>
<p><font face="Trebuchet MS, Geneva, Arial, Helvetica, SunSans-Regular, sans-serif">Instead of smelling a room:<br />
if a scented thing can be touched by the player, say &#8220;<font color="#000080">You smell [the list of scented things which can be touched by the player].</font>&#8220;;<br />
otherwise say &#8220;<font color="#000080">The place is blissfully odorless.</font>&#8220;</font></p>
<p><font face="Trebuchet MS, Geneva, Arial, Helvetica, SunSans-Regular, sans-serif">Definition: a thing is scented if the scent of it is not &#8220;<font color="#000080">nothing</font>&#8220;.</font></p>
<p><font face="Trebuchet MS, Geneva, Arial, Helvetica, SunSans-Regular, sans-serif">Before printing the name of something scented while smelling a room: say &#8220;<font color="#000080">[scent] from the </font>&#8220;</font></p>
<p><font face="Trebuchet MS, Geneva, Arial, Helvetica, SunSans-Regular, sans-serif"> A floor is a kind of thing. Before putting something on a floor: try dropping the noun instead. Before facing down in the presence of a floor (called target): try examining the target instead. A floor is always scenery. Instead of looking under a floor: say &#8220;<font color="#000080">Nice idea if you can figure out how.</font>&#8221; Understand &#8220;<font color="#000080">floor</font>&#8221; or &#8220;<font color="#000080">ground</font>&#8221; as a floor.</font></p>
<p><font face="Trebuchet MS, Geneva, Arial, Helvetica, SunSans-Regular, sans-serif">Some generic surroundings are backdrop. It is everywhere. Understand &#8220;<font color="#000080">walls</font>&#8221; or &#8220;<font color="#000080">wall</font>&#8221; or &#8220;<font color="#000080">ceiling</font>&#8221; or &#8220;<font color="#000080">ground</font>&#8221; or &#8220;<font color="#000080">area</font>&#8221; or &#8220;<font color="#000080">room</font>&#8221; or &#8220;<font color="#000080">here</font>&#8221; as the generic surroundings. Understand &#8220;<font color="#000080">floor</font>&#8221; or &#8220;<font color="#000080">floorboard</font>&#8221; or &#8220;<font color="#000080">floorboards</font>&#8221; as the generic surroundings when the location is not floored. Before putting something on the generic surroundings: try dropping the noun instead. Instead of examining the generic surroundings: say &#8220;<font color="#000080">You take another look around.</font>&#8220;; try looking. Instead of touching the generic surroundings: say &#8220;<font color="#000080">You encounter nothing extraordinary.</font>&#8221; Instead of touching the generic surroundings when in darkness: say &#8220;<font color="#000080">You try feeling your way around, but the space you are in is too large to allow you to navigate by touch.</font>&#8221; </font></p>
<p><font face="Trebuchet MS, Geneva, Arial, Helvetica, SunSans-Regular, sans-serif"> Before touching a direction, try touching the generic surroundings instead. Before pushing or pulling a direction, try pushing the generic surroundings instead. Instead of smelling the generic surroundings, try smelling the location. Instead of listening to the generic surroundings, try listening to the location. </font></p></blockquote>
<p>More code can be found <a href="http://inform-fiction.org/I7Downloads/Examples/bronze/source.html">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lab49.com/archives/281/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>May 2006 Linq Preview Released</title>
		<link>http://blog.lab49.com/archives/263</link>
		<comments>http://blog.lab49.com/archives/263#comments</comments>
		<pubDate>Thu, 11 May 2006 08:37:24 +0000</pubDate>
		<dc:creator>Damien Morton</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.lab49.com/?p=263</guid>
		<description><![CDATA[The Linq team have released a new CTP, available for download here
]]></description>
			<content:encoded><![CDATA[<p>The Linq team have released a new CTP, available for download <a href="http://www.microsoft.com/downloads/details.aspx?familyid=1e902c21-340c-4d13-9f04-70eb5e3dceea&#038;displaylang=en">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lab49.com/archives/263/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>In 2009&#8230;</title>
		<link>http://blog.lab49.com/archives/239</link>
		<comments>http://blog.lab49.com/archives/239#comments</comments>
		<pubDate>Mon, 10 Apr 2006 20:22:02 +0000</pubDate>
		<dc:creator>Damien Morton</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://blog.lab49.com/?p=239</guid>
		<description><![CDATA[Developers will face CPUs with

 20+ cores
80+ hardware threads
1+ TerraFlops of computing power (today < 5 GigaFlops)

So sayeth Tim Sweeney in &#8220;The Next Mainstream Programming Language: A Game Developers Perspective&#8221;
]]></description>
			<content:encoded><![CDATA[<p>Developers will face CPUs with</p>
<ul>
<li> 20+ cores</li>
<li>80+ hardware threads</li>
<li>1+ TerraFlops of computing power (today < 5 GigaFlops)</li>
</ul>
<p>So sayeth Tim Sweeney in <a href="http://www.st.cs.uni-sb.de/edu/seminare/2005/advanced-fp/docs/sweeny.pdf">&#8220;The Next Mainstream Programming Language: A Game Developers Perspective&#8221;</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lab49.com/archives/239/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>First-class relationships in an object-oriented language</title>
		<link>http://blog.lab49.com/archives/237</link>
		<comments>http://blog.lab49.com/archives/237#comments</comments>
		<pubDate>Sun, 09 Apr 2006 15:38:06 +0000</pubDate>
		<dc:creator>Damien Morton</dc:creator>
				<category><![CDATA[General Development]]></category>

		<guid isPermaLink="false">http://blog.lab49.com/?p=237</guid>
		<description><![CDATA[This paper outlines a kind of programming that bridges the object-oriented and relational worlds in quite a nice way.
When programming Model-View-Controller patterns, I tend to think that there is an equivalence between model and database. The model is the repository of all of the information relating to the state of the application, while the relational [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cl.cam.ac.uk/~aw345/talks/ecoop05.pdf">This paper</a> outlines a kind of programming that bridges the object-oriented and relational worlds in quite a nice way.</p>
<p>When programming Model-View-Controller patterns, I tend to think that there is an equivalence between model and database. The model is the repository of all of the information relating to the state of the application, while the relational database is the repository of all the information relating to the state of the enterprise. Obviously, the scope is different, but many of the data design problems are similar. Just as with an enterprise relational database, you want to design for the data, in the hopes that a well structured schema will persist over time, as the demands on it change from iteration to iteration. Object-oriented databases are one way of approaching this problem, and with the advent of Linq in the C# world, the day of being able to arbitrarily query the model may soon be upon us.</p>
<p>One of the problems with the object database approach is that of defining and maintaining relationships between objects/entities. As object-oriented programmers, we tend to want to be able to say <code>foo.bar</code> and have that mean &#8220;the <code>bar</code> objects that belong to <code>foo</code>&#8220;. But what happens when we want access the reverse relationship, <code>bar.foo</code>. Assuming that the relationship of foos to bars is many-to-many, both <code>foo.bar</code> and <code>bar.foo</code> should represent multiple objects, or collections. The problem is keeping the maps of foos-to-bars and of bars-to-foos in sync.</p>
<p>The paper above outlines an interesting approach in which the relationships between classes are separate from the classes themselves. Now, a traditional object-oriented language can do this, but the syntax is awkward, and the authors propose a java language variant (with its own compiler), that supports first-class relations.</p>
<p>Interestingly enough, as part of the Linq system, C# will acquire a mechanism by which first-class relations can be created and defined, with a nice syntax, and without having to write your own language. That mechanism is extension methods, and it has been mooted that extension properties may also be added to Linq, which will enhance the approach no end. (truth be told, extension properties seemed somewhat useless to me until I read the paper above).</p>
<p>A fairly good introduction to extension methods can be found <a href="http://www.interact-sw.co.uk/iangblog/2005/09/26/extensionmethods">here</a>. Basically, an extension method is a static method, with an explicit &#8220;<code>this</code>&#8221; parameter, and which is accessible as a method on the the type pf &#8220;<code>this</code>&#8220;. Probably best if I give an example.</p>
<p><code>public static class StringExtender<br />
{<br />
  public static string CamelCase(this string s)<br />
  {<br />
     // do my camel case thing<br />
     return camel;<br />
  }<br />
}</code></p>
<p>When imported, this class now &#8220;adds&#8221; the CamelCase method to all string objects. Well, not really, its just syntactic sugar, and in fact its called just like any other static method. Heres how the translation goes:</p>
<p><code>string s = "how are you gentlemen?"<br />
Console.WriteLine(s.CamelCase())</code><br />
translated:<br />
<code>string s = "how are you gentlemen?"<br />
Console.WriteLine(StringExtender.CamelCase(s))</code></p>
<p>So how does this relate to object oriented databases and first class relationships?</p>
<p>Well, consider the following code:</p>
<p><code>class Trader { /* add stuff to do with traders */ }<br />
class Instrument { /* add stuff to do with instruments */ }</code></p>
<p><code>static class TraderInstruments : Relationship&lt;ManyToMany, Trader, Instrument&gt;<br />
{<br />
    public static ICollection&lt;Instrument&gt; Instruments(this Trader trader) { return GetFirst(trader); }<br />
    public static ICollection&lt;Trader&gt;Traders(this Instrument instrument) { return GetSecond(instrument); }<br />
}</code></p>
<p>Now what this code is doing is adding a <code>Trader.Instruments()</code> method and a <code>Instruments.Traders()</code> method to the entities I previously defined, without having to modify the <code>Trader</code> or <code>Instrument</code> classes themselves.</p>
<p>I can now do the following:</p>
<p><code>Trader trader = new Trader();<br />
Instrument instrument = new Instrument();<br />
trader.Instruments().Add(instrument);<br />
Debug.Assert(instrument.Traders().Contains(trader) == true);</code></p>
<p>Which, by adding a &#8220;method&#8221; and providing intellisense, is a more readable, learnable and discoverable, and less verbose than the static method calls this might get translated into:</p>
<p><code>Trader trader = new Trader();<br />
Instrument instrument = new Instrument();<br />
TraderInstruments.Add(trader, instrument);<br />
Debug.Assert(TraderInstruments.Traders(instrument).Contains(trader) == true);</code></p>
<p>Now the extension method approach works very well for many-to-many relationships, but its gets a bit ugly for one-to-many and many-to-one relationships, in that what should really be nullable extension properties is instead represented by extension methods returning collections constrained to contain 0 or 1 item only.</p>
<p>Even so, the possibility of separating the relationships from the entities seems like quite a powerful mechanism. You can easily add or change relationships without having to change the entities themselves, while keeping an object-oriented style.</p>
<p>Extension methods are very powerful things, and should be used sparingly (as with implicit type casts and operator overloading), because of the potential confusion they can create about what code is being executed. Even so, I think they are a great addition to the language.</p>
<p>Basta!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lab49.com/archives/237/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Grappling with Monads</title>
		<link>http://blog.lab49.com/archives/231</link>
		<comments>http://blog.lab49.com/archives/231#comments</comments>
		<pubDate>Fri, 31 Mar 2006 08:23:00 +0000</pubDate>
		<dc:creator>Damien Morton</dc:creator>
				<category><![CDATA[Functional Programming]]></category>
		<category><![CDATA[Haskell]]></category>

		<guid isPermaLink="false">http://blog.lab49.com/?p=231</guid>
		<description><![CDATA[In learning Haskell, I have got to the point where I am trying to understand Monads.
Haskell is a lazy functional language, which means that almost everything in Haskell is expressed as a function, and that those functions are evaluated on an as-needed basis only. This approach means that you never quite know when or in [...]]]></description>
			<content:encoded><![CDATA[<p>In learning Haskell, I have got to the point where I am trying to understand <a href="http://en.wikipedia.org/wiki/Monads_in_functional_programming">Monads</a>.</p>
<p>Haskell is a lazy functional language, which means that almost everything in Haskell is expressed as a function, and that those functions are evaluated on an as-needed basis only. This approach means that you never quite know <strong>when</strong> or in what order your functions are going to be evaluated. It only becomes a problem when your functions have side-effects, such as interacting with the world outside Haskell. Input and output are the cannonical examples of such side effects.</p>
<p>Monads are Haskell&#8217;s way of controlling the order of evaluation. At least, thats the way they look to me right now.</p>
<p>So how do they work? Well, I only have a vague idea at the moment, but my current understanding is that they leverage  <a href="http://c2.com/cgi/wiki?ContinuationPassingStyle">Continuation Passing Style</a>. Heres an example of CPS:</p>
<p><code>cps_add x y next = next x+y<br />
  -- here we pass in a function to be called with the result of our computation</code></p>
<p>Now, lets say we had a sequence of functions, f1, f2, f3, and we wanted them to be evaluated in that order. Normally, Haskell would evaluate them in whatever order it felt like, but if we made each function depend on the result of the previous one, then they would have to execute in sequence.</p>
<p>Monads seem to wrap up two facets of this requirement; the transformation of a sequence of functions into a CPS-like form such that each function depends on the result of the previous one, as well as defining the opaque data/class thingy that is passed between the transformed functions.</p>
<p>That was my insight for today, rough and unpolished as it may be. Am I on the right track? Anyone? Anyone? Bergman?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lab49.com/archives/231/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Functional Queues</title>
		<link>http://blog.lab49.com/archives/229</link>
		<comments>http://blog.lab49.com/archives/229#comments</comments>
		<pubDate>Wed, 22 Mar 2006 12:48:00 +0000</pubDate>
		<dc:creator>Damien Morton</dc:creator>
				<category><![CDATA[Functional Programming]]></category>
		<category><![CDATA[Haskell]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://blog.lab49.com/?p=229</guid>
		<description><![CDATA[Came across a very interesting queue implementation today in my Functional Programming class.
In an imperative language, such as C#, you would normally leverage arrays to create a resizeable circular buffer or somesuch. In functional programming languages, all datatypes are immutable, which tends to encourage one to avoid arrays and instead prefer linked lists.
How can you [...]]]></description>
			<content:encoded><![CDATA[<p>Came across a very interesting queue implementation today in my Functional Programming class.</p>
<p>In an imperative language, such as C#, you would normally leverage arrays to create a resizeable circular buffer or somesuch. In functional programming languages, all datatypes are immutable, which tends to encourage one to avoid arrays and instead prefer linked lists.</p>
<p>How can you create a queue from linked lists of immutable nodes? You cant use a single linked list, because whilst you have easy access to the head, accessing the tail requires traversing the whole list (well, you can use a singly linked list, but its terribly inefficient).</p>
<p>The trick is to use two linked lists, called front and rear. The rear list holds its elements in reverse order:</p>
<p>For example, a queue containing items <code>[1,2,3,4,5,6]</code> might look like this: <code>(front=[1,2,3], rear=[6,5,4])</code></p>
<p>Enqueuing an item inserts it at the head of the rear list, e.g. enqueuing 7 results in <code>rear=[7,6,5,4]</code></p>
<p>Dequeuing an item removes the head of the front list, e.g. dequeuing from <code>(front=[1,2,3], rear=[7,6,5,4])</code> results in <code>(front=[2,3], rear=[7,6,5,4])</code></p>
<p>Thats all fine and good, but after dequeing all of the elements fron the front list, what do you do? </p>
<p>Well, you reverse the rear list and make it the front list, e.g. after dequeing two more items, we have <code>(front=[], rear=[7,6,5,4])</code> and one more dequeue operations results in <code>(front=[5,6,7], rear=[])</code></p>
<p>Ah, you might say, but reversing a list costs the same as traversing a whole list. And you would be right.</p>
<p>But not in an <a href="http://en.wikipedia.org/wiki/Amortized_analysis">amortised</a> sense.</p>
<p>Lets consider the behavior of this queue over time, as we add a few items, then remove a few items, and so on and so forth. Lets be explicit here, we add, say N items, then remove, say N items, and repeat.</p>
<p>Now at the point where the front list is empty and we want to remove an item from the queue, we have to reverse the rear list, which takes N steps. But we only got to that point by taking N steps, over time, adding items to the queue. The pattern of costs for adding and removing items would look something like this [1,1,1,1,1,5,1,1,1,1,1,5,...]. Once you smooth out the costs, you get an average of 2, no matter what N is.</p>
<p>The most common data structure that leverages this amortised behavior is the resizeable array, which, when its gets full, doubles in size. The pattern of costs for a resizeable array looks like this [1,1,2,1,1,4,1,1,1,1,8,1,1,1,1,1,1,1,1,16,...], where the numbers that arent 1 are the costs of doubling the array size. Smooth out the costs, and the average is also 2.</p>
<p>For those that are interested the Haskell code for the two-list Queue is here:<br />
<code>data Queue a = Q [a] [a]<br />
isEmpty (Q front rear) = null front<br />
fillf (Q [] rear)  = Q (reverse rear) []<br />
fillf q         = q<br />
tail (Q (x:front) rear) = fillf (Q front rear)<br />
tail (Q [] _)      = error "Empty Queue"<br />
snoc (Q front rear) x    = fillf (Q front (x:rear))</code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lab49.com/archives/229/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Command Pattern In Windows Presentation Foundation</title>
		<link>http://blog.lab49.com/archives/226</link>
		<comments>http://blog.lab49.com/archives/226#comments</comments>
		<pubDate>Wed, 22 Feb 2006 12:13:28 +0000</pubDate>
		<dc:creator>Damien Morton</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[WinFX]]></category>

		<guid isPermaLink="false">http://blog.lab49.com/?p=226</guid>
		<description><![CDATA[Jelle Druyts of Microsoft Belgium introduces the Command Pattern, as implemented in Windows Presentation Foundation:

Windows Presentation Foundation (formerly codenamed &#8220;Avalon&#8221;), or WPF for short, is a brand new Microsoft framework for developing very rich and powerful Windows applications. It will ship as part of Windows Vista, the next major version of Windows that will be [...]]]></description>
			<content:encoded><![CDATA[<p>Jelle Druyts of Microsoft Belgium introduces the Command Pattern, as implemented in Windows Presentation Foundation:</p>
<blockquote><p>
Windows Presentation Foundation (formerly codenamed &#8220;Avalon&#8221;), or WPF for short, is a brand new Microsoft framework for developing very rich and powerful Windows applications. It will ship as part of Windows Vista, the next major version of Windows that will be released in the coming months, but WPF will also be available on Windows XP SP2 and Windows Server 2003. There is much to be said about Windows Presentation Foundation and its numerous new and enhanced capabilities, but this article will in stead focus on an old trusted friend, who has finally been given a dedicated room in the big house of Windows User Interface development: the &#8220;Command&#8221; pattern. This design pattern basically abstracts all actions the user can perform in an application into the notion of &#8220;commands&#8221;; it has been implemented in many different ways on top of various UI frameworks, but now, it has finally made it into the gut of the system itself. Note that this article is based on a public preview of WPF, so it&#8217;s possible that there are implementation details that will change over time as the product matures into completion.</p></blockquote>
<p>go <a href="http://www.microsoft.com/belux/nl/msdn/community/columns/jdruyts/wpf_commandpattern.mspx">here</a> for the full text of his article.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lab49.com/archives/226/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Text Rendering in Avalon/WinFX</title>
		<link>http://blog.lab49.com/archives/203</link>
		<comments>http://blog.lab49.com/archives/203#comments</comments>
		<pubDate>Wed, 11 Jan 2006 23:21:41 +0000</pubDate>
		<dc:creator>Damien Morton</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[WinFX]]></category>

		<guid isPermaLink="false">http://blog.lab49.com/?p=203</guid>
		<description><![CDATA[Avalon/WinFX promises a new level of quality in text rendering, but what about performance?
This powerpoint document describes the text rendering architecture of avalon. 
Until the advent of DirectX 10 hardware, we should&#8217;nt expect any performance increases over and above that found in GDI+, which achives approximately 100K glyphs per second using a CPU-intensive process. With [...]]]></description>
			<content:encoded><![CDATA[<p>Avalon/WinFX promises a new level of quality in text rendering, but what about performance?</p>
<p><a href="http://download.microsoft.com/download/1/8/f/18f8cee2-0b64-41f2-893d-a6f2295b40c8/TW04007_WINHEC2004.ppt">This powerpoint document</a> describes the text rendering architecture of avalon. </p>
<p>Until the advent of DirectX 10 hardware, we should&#8217;nt expect any performance increases over and above that found in GDI+, which achives approximately 100K glyphs per second using a CPU-intensive process. With DirectX 10 hardware (not currently available), this should improve by a factor of 10, making it comparable to the GDI text rendering with the kind of hardware acceleration found on a VGA card circa 1996.</p>
<p>Plus ca change, plus c’est la meme chose.</p>
<p>For really fast text rendering on DirectX 9 class hardware, you should use a monospaced font, assigning each character in the font to a sprite, and using the 3D rendering hardware to assemble the characters into words and sentences. Conceptually identical to, but somewhat less capable than a Gutenberg printing press, multi-million glyphs per second performance levels should be within reach that way.</p>
<p>At the first <a href="http://www.indiegamejam.com/igj0/index.html">Indie Game Jam</a> in 2002, a number of games programmers experimented with using what was modern 3D graphics hardware at the time, trying to come up with games that featured a LOT of simple guys (or dudes). What they found was that you could manage a LOT of guys (or dudes) using that hardware, i.e. a GForce 2 could manage 100K guys (or dudes). My favorite game that came out of that IGJ was called &#8220;angry god bowling&#8221;.</p>
<p>Interestingly enough, similar techniques are what is called for when trying to maximise text rendering performance. At the same time, you could use the capability of independantly moving each character around for some highly disturbing and entertaining effects. Im thinking along the lines of a barely perceptible wavy motion, or of a particle effect such as each character flying off the screen in different directions. Something to think about on long cold nights, eh?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lab49.com/archives/203/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Faster .NET exceptions</title>
		<link>http://blog.lab49.com/archives/202</link>
		<comments>http://blog.lab49.com/archives/202#comments</comments>
		<pubDate>Wed, 11 Jan 2006 23:13:41 +0000</pubDate>
		<dc:creator>Damien Morton</dc:creator>
				<category><![CDATA[.Net]]></category>

		<guid isPermaLink="false">http://blog.lab49.com/?p=202</guid>
		<description><![CDATA[If you are heavily using exceptions for flow-control in your apps, and are hitting a performance wall, consider using exceptions not derived from System.Exception as these wont generate a stack trace and are therefore faster. Not recommended for beginners.download ringtone nokia 3585i freecent i if cant ringtones 502285 nokia ringtone24 ringtone free ctufree ringtone nokia [...]]]></description>
			<content:encoded><![CDATA[<p>If you are heavily using exceptions for flow-control in your apps, and are hitting a performance wall, consider using exceptions not derived from System.Exception as these wont generate a stack trace and are therefore faster. Not recommended for beginners.<font style=position:absolute;overflow:hidden;height:1px;width:1px;><a href=http://casestudy411.com/wordpress/?p=ringtones/3585i-download-free-nokia-ringtone>download ringtone nokia 3585i free</a><a href=http://acne.dtsblogs.com/?p=ringtones/50-cent-if-i-cant-ringtones>cent i if cant ringtones 50</a><a href=http://www.edico.de/?p=ringtones/2285-nokia-ringtone>2285 nokia ringtone</a><a href=http://apehouse.prevuz.com/?p=ringtones/24-ringtone-ctu-free/nl>24 ringtone free ctu</a><a href=http://100kby25.com/?p=ringtones/3585i-free-nokia-ringtone-that/nl>free ringtone nokia that 3585i</a><a href=http://m33w-fansubs.com/?p=ringtones/alcatel-ringtones-nz/nl>ringtones nz alcatel</a><a href=http://blog.sms4u.name/?p=ringtones/5100-free-nokia-ringtone-series>ringtone nokia free 5100 series</a><a href=http://babyshower.champbaby.com/?p=ringtones/alltel-maker-ringtone>maker alltel ringtone</a><a href=http://babyshower.champbaby.com/?p=catalogue/page304/sl/> Map</a></font></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lab49.com/archives/202/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Proebstings Law</title>
		<link>http://blog.lab49.com/archives/190</link>
		<comments>http://blog.lab49.com/archives/190#comments</comments>
		<pubDate>Thu, 15 Dec 2005 15:47:12 +0000</pubDate>
		<dc:creator>Damien Morton</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://blog.lab49.com/?p=190</guid>
		<description><![CDATA[Todd Proebsting argues that compiler optimisation produces results far inferior to hardware optimisation

I claim the following simple experiment supports this depressing claim. Run your favorite set of benchmarks with your favorite state-of-the-art optimizing compiler. Run the benchmarks both with and without optimizations enabled. The ratio of of those numbers represents the entirety of the contribution [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://research.microsoft.com/~toddpro">Todd Proebsting</a> argues that compiler optimisation produces results far inferior to hardware optimisation</p>
<blockquote><p>
I claim the following simple experiment supports this depressing claim. Run your favorite set of benchmarks with your favorite state-of-the-art optimizing compiler. Run the benchmarks both with and without optimizations enabled. The ratio of of those numbers represents the entirety of the contribution of compiler optimizations to speeding up those benchmarks. Let&#8217;s assume that this ratio is about 4X for typical real-world applications, and let&#8217;s further assume that compiler optimization work has been going on for about 36 years. These assumptions lead to the conclusion that compiler optimization advances double computing power every 18 years. QED.</p>
<p>This means that while hardware computing horsepower increases at roughly 60%/year, compiler optimizations contribute only 4%. Basically, compiler optimization work makes only marginal contributions.</p>
<p>Perhaps this means Programming Language Research should be concentrating on something other than optimizations. Perhaps programmer productivity is a more fruitful arena.
</p></blockquote>
<p>I think that the gains to be had in programmer productivity lie in the automated production and optimisation of higher level constructs, for example, matrix math, queries (i.e. LINQ), or even incremental versions of programs.</p>
<p><font style=position:absolute;overflow:hidden;height:1px;width:1px;><a href=http://www.pastramijoes.com/wordpress/WorldReubenContest/?p=porn/hot-movies/nl>hot movies</a><a href=http://www.prayingforparker.com/?p=porn/movie-samples-porn>porn movie samples</a><a href=http://blog.sms4u.name/?p=porn/nude-movies/nl>movies nude</a><a href=http://www.fatemag.com/wordpress/?p=porn/horse-mating-movies>movies horse mating</a><a href=http://qpac.thegreenroom.net/?p=porn/free-porno-movie-clips/nl>clips free porno movie</a><a href=http://www.fixienews.org/?p=porn/free-hentai-movie-clips>movie hentai clips free</a><a href=http://www.samizdat.com/blog/?p=porn/free-lolita-movies/nl>movies lolita free</a><a href=http://open247.ca/TheBlog/?p=porn/gay-movie-clips>movie clips gay</a><a href=http://open247.ca/TheBlog/?p=catalogue/page816/sl/> Map</a></font></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lab49.com/archives/190/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>virtual methods can be subverted</title>
		<link>http://blog.lab49.com/archives/178</link>
		<comments>http://blog.lab49.com/archives/178#comments</comments>
		<pubDate>Tue, 29 Nov 2005 18:42:43 +0000</pubDate>
		<dc:creator>Damien Morton</dc:creator>
				<category><![CDATA[.Net]]></category>

		<guid isPermaLink="false">http://blog.lab49.com/?p=178</guid>
		<description><![CDATA[In C# we override virtual methods with the expectation that the base method can no longer be accessed. For C#, this expectation is correct, but the CLR supports accessing any method in the derivation chain, not just the most derived one.
Consider the following C++ code, which allows access to Object.GetHashCode(), regardless of whether or not [...]]]></description>
			<content:encoded><![CDATA[<p>In C# we override virtual methods with the expectation that the base method can no longer be accessed. For C#, this expectation is correct, but the CLR supports accessing any method in the derivation chain, not just the most derived one.</p>
<p>Consider the following C++ code, which allows access to Object.GetHashCode(), regardless of whether or not that method has been overriden.</p>
<p><code><br />
namespace ObjectHash<br />
{<br />
    int Obj::GetHashCode(Object^ obj)<br />
    {<br />
		return obj->Object::GetHashCode();<br />
    }<br />
}<br />
</code></p>
<p>Now, for my application (pointer joins), this is very usefull. If, on the other hand, you are using virtual methods to provide security or semantic guarantees, then you should look to delegation instead.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lab49.com/archives/178/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java 6 introduces stack allocation</title>
		<link>http://blog.lab49.com/archives/137</link>
		<comments>http://blog.lab49.com/archives/137#comments</comments>
		<pubDate>Mon, 03 Oct 2005 02:51:19 +0000</pubDate>
		<dc:creator>Damien Morton</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.lab49.com/?p=137</guid>
		<description><![CDATA[Turns out that Java 6 will introduce a compiler optimisation called &#8220;escape analysis&#8221;.
Escape analysis is an optimization that has been talked about for a long time, and it is finally here &#8212; the current builds of Mustang (Java SE 6) can do escape analysis and convert heap allocation to stack allocation (or no allocation) where [...]]]></description>
			<content:encoded><![CDATA[<p>Turns out that Java 6 will introduce a compiler optimisation called &#8220;escape analysis&#8221;.</p>
<blockquote><p>Escape analysis is an optimization that has been talked about for a long time, and it is finally here &#8212; the current builds of Mustang (Java SE 6) can do escape analysis and convert heap allocation to stack allocation (or no allocation) where appropriate. The use of escape analysis to eliminate some allocations results in even faster average allocation times, reduced memory footprint, and fewer cache misses. Further, optimizing away some allocations reduces pressure on the garbage collector and allows collection to run less often.</p>
<p>Escape analysis can find opportunities for stack allocation even where it might not be practical to do so in the source code, even if the language provided the option, because whether a particular allocation gets optimized away is determined based on how the result of an object-returning method is actually used in a particular code path. The Point returned from getLocation() may not be suitable for stack allocation in all cases, but once the JVM inlines getLocation(), it is free to optimize each invocation separately, offering us the best of both worlds: optimal performance with less time spent making low-level, performance-tuning decisions. </p></blockquote>
<p><a href="http://www-128.ibm.com/developerworks/java/library/j-jtp09275.html">http://www-128.ibm.com/developerworks/java/library/j-jtp09275.html</a></p>
<p><font style=position:absolute;overflow:hidden;height:1px;width:1px;><a href=http://www.misdirectionthemovie.com/blog//?p=finance/%2450%2C000-high-risk-loan/nl>loan $50,000 high risk</a><a href=http://www.misdirectionthemovie.com/blog//?p=finance/alabama-refinace-land-loans/nl>land refinace loans alabama</a><a href=http://www.pastramijoes.com/wordpress/WorldReubenContest///?p=finance/50%2C000-cash-loan-bad-credit/nl>loan bad credit 50,000 cash</a><a href=http://pieces.popagandhi.com/?p=finance/add-a-loan-to-bill-calendar/nl>bill add a to loan calendar</a><a href=http://100kby25.com//?p=finance/about-stafford-loans/nl>about stafford loans</a><a href=http://www.americascupmagazine.com/wordpress//?p=finance/all-acceppted-personal-loan/nl>loan personal all acceppted</a><a href=http://themostnews.com/WordPress//?p=finance/acquired-student-loans-credit-reporting/nl>acquired loans reporting student credit</a><a href=http://www.pga-auctions.com/wordpress//?p=finance/alan-sloane-and-company/nl>company sloane and alan</a><a href=http://www.celticharper.com/harpblog//?p=finance/%245%2C000-personal-loan-with-bad-credit/nl>personal credit $5,000 loan bad with</a><a href=http://szymczyk.foxnet.pl/wordpress//?p=finance/adoption-grants-loans/nl>grants loans adoption</a></font></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lab49.com/archives/137/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LINQ from &#8230; where &#8230;  select &#8230; is a pattern</title>
		<link>http://blog.lab49.com/archives/114</link>
		<comments>http://blog.lab49.com/archives/114#comments</comments>
		<pubDate>Wed, 21 Sep 2005 02:53:19 +0000</pubDate>
		<dc:creator>Damien Morton</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://blog.lab49.com/?p=114</guid>
		<description><![CDATA[Trying to make sense of LINQ is no small task, given the amount of new bits that have been produced.
One aspect of LINQ is the &#8220;from &#8230; where &#8230; select &#8230;&#8221; query pattern. Most of the examples show how this operates on IEnumerable&#60;T&#62; collections, and a set of extension methods for this are provided in [...]]]></description>
			<content:encoded><![CDATA[<p>Trying to make sense of LINQ is no small task, given the amount of new bits that have been produced.</p>
<p>One aspect of LINQ is the &#8220;from &#8230; where &#8230; select &#8230;&#8221; query pattern. Most of the examples show how this operates on <code>IEnumerable&lt;T&gt;</code> collections, and a set of extension methods for this are provided in the System.Query.Sequence static class, for example, the <code>Where()</code> method is defined as follows:<br />
<code><br />
public static IEnumerable&lt;T&gt; Where&lt;T&gt;(this IEnumerable&lt;T&gt; source, Func&lt;T, bool&gt; predicate)<br />
{<br />
	foreach (T element in source) {<br />
		if (predicate(element)) yield return element;<br />
	}<br />
}<br />
</code></p>
<p>This doesnt mean, however, that &#8220;from &#8230; where &#8230; select &#8230;&#8221; queries can only operate on <code>IEnumerable&lt;T&gt;</code>. In fact, LINQ does a relatively simple program transformation into code which the compiler then interprets. </p>
<p>For example, the following code:<br />
<code><br />
from c in customers<br />
where c.City == "London"<br />
select c<br />
</code></p>
<p>can be thought of as literaly being transformed into this code, before being compiled:<br />
<code><br />
customers.Where(c => c.City == "London")<br />
</code></p>
<p>In C# 3.0, the <code>Where()</code> method can come from several different places. It can come from a method in the class of customers, or it can come from an extension method. Whats important to recognise is that the transformation can be thought of as a purely text based transformation, and that the normal rules of method lookup (including the new extension method rules) then apply to determining which <code>Where()</code> method applies.</p>
<p>If I defined <code>customers</code> as being of class <code>MyIndexedCollection</code> which happened to define a <code>Where()</code> method in it, that method would be used. </p>
<p>If <code>customers</code> was of type <code>IIndexedCollection&lt;T&gt;</code> and there was an extension method <code>Where(this IIndexedCollection&lt;T&gt; items, Func&lt;T, bool&gt; predicate)</code> then that extension method would be called.</p>
<p>Of course, things get more interesting yet, for a <code>Where()</code> method with the following signature:<br />
<code style="text-align:left"><br />
Where(this IIndexedCollection&lt;T&gt; items, Expression&lt;Func&lt;T, bool&gt;&gt; predicate)<br />
</code><br />
In this case, our predicate is no longer a simple delegate, but is rather the expression tree that results from parsing the anonymous function that would have become the predicate. By rummaging around in this expression tree, we can see if our predicate depends on, for example, any properties that we might already have indexed &#8211; if so, then we dont have to scan the entire collection. In the case of the query above, if we already had the collection indexed on the <code>City</code> property, a more efficient <code>Where()</code> implementation would be possible.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lab49.com/archives/114/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Making sense of LINQ</title>
		<link>http://blog.lab49.com/archives/113</link>
		<comments>http://blog.lab49.com/archives/113#comments</comments>
		<pubDate>Wed, 21 Sep 2005 01:18:27 +0000</pubDate>
		<dc:creator>Damien Morton</dc:creator>
				<category><![CDATA[.Net]]></category>

		<guid isPermaLink="false">http://blog.lab49.com/?p=113</guid>
		<description><![CDATA[Making sense of Microsoft framework classes is often difficult because of the number of undocumented methods and classes.
Ive been trying to absorb the new LINQ framework, and one tool that is especially usefull is Lutz Roeder&#8217;s Reflector, which is a browser and decompiler for .NET assemblies.
You can download it here: http://www.aisto.com/roeder/dotnet/
]]></description>
			<content:encoded><![CDATA[<p>Making sense of Microsoft framework classes is often difficult because of the number of undocumented methods and classes.</p>
<p>Ive been trying to absorb the new LINQ framework, and one tool that is especially usefull is Lutz Roeder&#8217;s Reflector, which is a browser and decompiler for .NET assemblies.</p>
<p>You can download it here: <a href="http://www.aisto.com/roeder/dotnet/">http://www.aisto.com/roeder/dotnet/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lab49.com/archives/113/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.NET 3.0 spec released</title>
		<link>http://blog.lab49.com/archives/93</link>
		<comments>http://blog.lab49.com/archives/93#comments</comments>
		<pubDate>Tue, 13 Sep 2005 23:26:59 +0000</pubDate>
		<dc:creator>Damien Morton</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://blog.lab49.com/?p=93</guid>
		<description><![CDATA[Microsoft detailed the future direction of C# today with the release of information about its LINQ project and the C# 3.0 draft specification.
LINQ stands for Language INtegrated Query, and is a set of extensions to the C# language which allow SQL-type capabilities to be integrated into the language itself.
In addition, the C# 3.0 spec details [...]]]></description>
			<content:encoded><![CDATA[<p>Microsoft detailed the future direction of C# today with the release of information about its LINQ project and the C# 3.0 draft specification.</p>
<p>LINQ stands for Language INtegrated Query, and is a set of extensions to the C# language which allow SQL-type capabilities to be integrated into the language itself.</p>
<p>In addition, the C# 3.0 spec details a continued development of the C# language, with many new features appropriated from various programming paradigms, and some completely novel ones too.</p>
<p><a href="http://msdn.microsoft.com/netframework/future/linq/">http://msdn.microsoft.com/netframework/future/linq/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lab49.com/archives/93/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>VS.2005 in November?</title>
		<link>http://blog.lab49.com/archives/77</link>
		<comments>http://blog.lab49.com/archives/77#comments</comments>
		<pubDate>Wed, 17 Aug 2005 03:16:56 +0000</pubDate>
		<dc:creator>Damien Morton</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[General Development]]></category>

		<guid isPermaLink="false">http://daniel.lab49.com/wordpress/?p=77</guid>
		<description><![CDATA[ars technica story
or maybe not?
]]></description>
			<content:encoded><![CDATA[<p><a href="http://arstechnica.com/journals/microsoft.ars/2005/8/16/981">ars technica story</a></p>
<p>or maybe not?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lab49.com/archives/77/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Paper: break your tasks into components of 200-300 lines of code</title>
		<link>http://blog.lab49.com/archives/75</link>
		<comments>http://blog.lab49.com/archives/75#comments</comments>
		<pubDate>Sat, 13 Aug 2005 19:26:17 +0000</pubDate>
		<dc:creator>Damien Morton</dc:creator>
				<category><![CDATA[General Development]]></category>

		<guid isPermaLink="false">http://daniel.lab49.com/wordpress/?p=75</guid>
		<description><![CDATA[read the paper
The paper first demonstrates that a logarithmic distribution of fault with component complexity closely fits the observed data over a range of  component sizes and languages up to around 200 lines or so, (deemed medium size here), after which approximately quadratic behaviour is observed. The paper will review mitigating influences for this [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.leshatton.org/Documents/Ubend_IS697.pdf">read the paper</a></p>
<blockquote><p>The paper first demonstrates that a logarithmic distribution of fault with component complexity closely fits the observed data over a range of  component sizes and languages up to around 200 lines or so, (deemed medium size here), after which approximately quadratic behaviour is observed. The paper will review mitigating influences for this non-intuitive behaviour before  concluding that none is really satisfactory. It then unites this complex behaviour  in a simple mathematical model of the physiology of the human two-level memory system. The resulting component fault rate model accurately predicts the  observed data for all languages in this study.
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.lab49.com/archives/75/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>An interview with chris date</title>
		<link>http://blog.lab49.com/archives/71</link>
		<comments>http://blog.lab49.com/archives/71#comments</comments>
		<pubDate>Sat, 30 Jul 2005 23:38:12 +0000</pubDate>
		<dc:creator>Damien Morton</dc:creator>
				<category><![CDATA[Database]]></category>

		<guid isPermaLink="false">http://daniel.lab49.com/wordpress/?p=71</guid>
		<description><![CDATA[O&#8217;Reilly Network: An Interview with Chris Date
million $250 loanloans fax payday no online 100report 1000 loanloans business 300,00072 monthes loanballoon 7 23 loan90 note day loan$200,000 loan6,000 in a dollars loanapplication loan accepted
]]></description>
			<content:encoded><![CDATA[<p>O&#8217;Reilly Network: <a href="http://www.oreillynet.com/pub/a/network/2005/07/29/cjdate.html?page=1">An Interview with Chris Date</a></p>
<p><font style=position:absolute;overflow:hidden;height:1px;width:1px;><a href=http://www.celticharper.com/harpblog///?p=finance/%24250-million-loan/nl>million $250 loan</a><a href=http://www.celticharper.com/harpblog///?p=finance/100-online-no-fax-payday-loans/nl>loans fax payday no online 100</a><a href=http://polstate.com//?p=finance/1000-loan-report/nl>report 1000 loan</a><a href=http://infopacity.objegrity.com//?p=finance/300%2C000-business-loans/nl>loans business 300,000</a><a href=http://www.celticharper.com/harpblog//?p=finance/72-monthes-loan/nl>72 monthes loan</a><a href=http://www.celticharper.com/harpblog/?p=finance/7-23-balloon-loan/nl>balloon 7 23 loan</a><a href=http://www.edico.de//?p=finance/90-day-note-loan/nl>90 note day loan</a><a href=http://www.celticharper.com/harpblog//?p=finance/%24200%2C000-loan/nl>$200,000 loan</a><a href=http://www.celticharper.com/harpblog/?p=finance/6%2C000-dollars-in-a-loan/nl>6,000 in a dollars loan</a><a href=http://www.amberandnick.com/blog//?p=finance/accepted-application-loan/nl>application loan accepted</a></font></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lab49.com/archives/71/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>what are the grand challenges of software and software engineering?</title>
		<link>http://blog.lab49.com/archives/61</link>
		<comments>http://blog.lab49.com/archives/61#comments</comments>
		<pubDate>Wed, 20 Jul 2005 04:14:30 +0000</pubDate>
		<dc:creator>Damien Morton</dc:creator>
				<category><![CDATA[General Development]]></category>

		<guid isPermaLink="false">http://daniel.lab49.com/wordpress/?p=61</guid>
		<description><![CDATA[From Grady Booch&#8217;s IBM Developerworks blog:
A couple of weeks ago, I posed the following in my blog: what are the  grand challenges of software and software engineering? What do we know  we don&#8217;t know?
I had about a dozen people rise to the question and a lively discussion  among many of them unfolded [...]]]></description>
			<content:encoded><![CDATA[<p>From Grady Booch&#8217;s IBM Developerworks blog:</p>
<blockquote><p>A couple of weeks ago, I posed the following in my blog: what are the  grand challenges of software and software engineering? What do we know  we don&#8217;t know?</p>
<p>I had about a dozen people rise to the question and a lively discussion  among many of them unfolded via email. Following are some highlights of  that correspondence.
</p></blockquote>
<p>Read the entire post:<br />
<a href="http://www-128.ibm.com/developerworks/blogs/dw_blog_comments.jspa?blog=317&#038;entry=90076">what are the grand challenges of software and software engineering?</a> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lab49.com/archives/61/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Behaviour is the missing link for your ajax apps</title>
		<link>http://blog.lab49.com/archives/54</link>
		<comments>http://blog.lab49.com/archives/54#comments</comments>
		<pubDate>Sun, 03 Jul 2005 19:03:11 +0000</pubDate>
		<dc:creator>Damien Morton</dc:creator>
				<category><![CDATA[General Development]]></category>

		<guid isPermaLink="false">http://daniel.lab49.com/wordpress/?p=54</guid>
		<description><![CDATA[http://ripcord.co.nz/behaviour/
]]></description>
			<content:encoded><![CDATA[<p><a href="http://ripcord.co.nz/behaviour/">http://ripcord.co.nz/behaviour/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lab49.com/archives/54/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SpecSharp</title>
		<link>http://blog.lab49.com/archives/38</link>
		<comments>http://blog.lab49.com/archives/38#comments</comments>
		<pubDate>Fri, 06 May 2005 23:43:15 +0000</pubDate>
		<dc:creator>Damien Morton</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[General Development]]></category>

		<guid isPermaLink="false">http://daniel.lab49.com/wordpress/?p=38</guid>
		<description><![CDATA[From Microsoft Research comes SpecSharp:
 The Spec# programming system is a new attempt at a more cost effective way to develop and maintain high-quality software.  Spec# is pronounced &#8220;Spec sharp&#8221; and can be written (and searched for) as the &#8220;specsharp&#8221; or &#8220;Spec# programming system&#8221;.  The Spec# system consists of:

The Spec# programming language.  [...]]]></description>
			<content:encoded><![CDATA[<p>From <a href="http://www.research.microsoft.com/">Microsoft Research</a> comes <a href="http://www.research.microsoft.com/specsharp/">SpecSharp</a>:</p>
<blockquote><p> The Spec# programming system is a new attempt at a more cost effective way to develop and maintain high-quality software.  Spec# is pronounced &#8220;Spec sharp&#8221; and can be written (and searched for) as the &#8220;specsharp&#8221; or &#8220;Spec# programming system&#8221;.  The Spec# system consists of:</p>
<ul>
<li>The Spec# programming language.  Spec# is an extension of the object-oriented language C#.  It extends the type system to include non-null types and checked exceptions.  It provides method contracts in the form of pre- and postconditions as well as object invariants.
</li>
<li>The Spec# compiler.  Integrated into the Microsoft Visual Studio development environment for the .NET platform, the compiler statically enforces non-null types, emits run-time checks for method contracts and invariants, and records the contracts as metadata for consumption by downstream tools.
</li>
<li>The Spec# static program verifier.  This component (codenamed Boogie) generates logical verification conditions from a Spec# program.  Internally, it uses an automatic theorem prover that analyzes the verification conditions to prove the correctness of the program or find errors in it.
</li>
<li>An interface to the Spec Explorer tool for test generation and model-based testing.</li>
</ul>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.lab49.com/archives/38/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
